Can I let a user select a contact from his iPhone's contact list in a web application?
So that only a s开发者_如何学JAVAingle contact is passed to the web application with the explicit permission of the user..
hum, in a "pure web app" (that you access from a URL in the mobile safari) I don't think you can. However, you can :
- embed a UIWebView (that accesses your webapp url) into a native app
- when the user clicks in your webapp on a HTML button "contacts", you open a page with a custom protocol (let's say myapp://contacts)
- then, in the delegate of the UIWebView, the callback
shouldStartLoadWithRequest
will be invoked. Check that the scheme of the URL from the NSURLRequest corresponds to myapp://contacts and based on that, trigger the opening of the ABPeoplePickerNavigationController to enable the selection of a "native" contact. - once the contact has been selected (delegate of the previous controller), you reinject this selection into your UIWebView using
[myWebView stringByEvaluatingJavascriptFromString:myJsFunctionToInjectContactInfo
I'm using this approach and it works fine.
精彩评论