SFSafariViewController - Interacting with the parent app from a web-page

僤鯓⒐⒋嵵緔 提交于 2019-12-12 13:00:23

问题


I'm trying to research a way to load a web view controller into an iOS app, such that the web page can communicate data back up to the parent.

Is this possible with SFSafariViewController? Is there some mechanism like post-messaging, which will let me send data back up to the native app?

Note: it's pretty important that I use SFSafariViewController, since I also need the web view to persist/share cookies with Safari.


回答1:


Since SFSafariViewControllers are not sandboxed, like all other implementations of UIWebView, it means that they have access to private information, such as cookies.

As a safety measure, the SFSafariViewController is then sandboxed from the rest of the app. The one way to communicate between it and your app is through a custom URL scheme.

The drawback of this is that you need to be in control of the web-service, and implement an API for this purpose (however you shouldn't really be able to access cookies otherwise).

You can follow this project to get you started.

Hope this helps,

Liam



来源:https://stackoverflow.com/questions/35164505/sfsafariviewcontroller-interacting-with-the-parent-app-from-a-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!