Can I access keychain from a webapp (javascript) on the iPhone? - Stack Overflow

The question is pretty much in the title ;-)Do you know if there is a webkit API for readingwriting fr

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 badges
Add a ment  | 

2 Answers 2

Reset to default 3

No, 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信