简体   繁体   English

我可以让用户从Web应用程序中其iPhone的联系人列表中选择联系人吗?

[英]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. 哼,在“纯网络应用”中(您可以通过移动浏览器中的URL访问),我认为您无法做到。 However, you can : 但是,您可以:

  • embed a UIWebView (that accesses your webapp url) into a native app 将UIWebView(可访问您的Web应用程序URL)嵌入到本机应用程序中
  • 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) 当用户在您的Web应用程序上单击HTML按钮“联系人”时,您会打开一个带有自定义协议的页面(例如myapp:// contacts)
  • then, in the delegate of the UIWebView, the callback shouldStartLoadWithRequest will be invoked. 然后,在UIWebView的委托中,将调用回调shouldStartLoadWithRequest 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. 检查来自NSURLRequest的URL方案是否对应于myapp:// contacts,并基于该方案触发ABPeoplePickerNavigationController的打开以启用“本地”联系人的选择。
  • once the contact has been selected (delegate of the previous controller), you reinject this selection into your UIWebView using [myWebView stringByEvaluatingJavascriptFromString:myJsFunctionToInjectContactInfo 一旦选择了联系人(以前的控制器的代表),就可以使用[myWebView stringByEvaluatingJavascriptFromString:myJsFunctionToInjectContactInfo所选内容重新注入到UIWebView中

I'm using this approach and it works fine. 我正在使用这种方法,并且效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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