The question is pretty much in the title ;-)
Do you know if there is a webkit API for reading/writing from the iPhone keychain ? That is, I would need to access the keychain from a webapp.
Thanks in advance !
The question is pretty much in the title ;-)
Do you know if there is a webkit API for reading/writing from the iPhone keychain ? That is, I would need to access the keychain from a webapp.
Thanks in advance !
Share Improve this question asked Nov 26, 2009 at 14:07 Eino GourdinEino Gourdin 4,5764 gold badges45 silver badges69 bronze badges2 Answers
Reset to default 3No, you can't.The keychain is only available from native apps. If you are using a UIWebView within a native app there are ways to bridge things around, but if it is a true web app with no native ponent it is not possible.
I don't have an answer on how to do this straight from javascript, and unlike the Mac WebView, the UIWebView API doesn't let you expose arbitrary Objective C code as javascript functions.
However you can use a workaround that has a similar effect using the load delegate:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType
{
if([[[request URL] scheme] isEqualToString:@"x-your-scheme"])
{
// parse the request and call the appropriate objc code here
[webView stringByEvaluatingJavaScriptFromString:@"send(results);"];
return NO;
}
return YES;
}
You trigger the load delegate by having your JS code load a "x-your-scheme://" URL.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745383124a4625322.html
评论列表(0条)