简体   繁体   中英

Can I let a user select a contact from his iPhone's contact list in a web application?

这样,在用户的明确许可下,只有一个联系人可以传递到Web应用程序。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM