SFSafariViewController-从网页与父应用程序进行交互 [英] SFSafariViewController - Interacting with the parent app from a web-page

查看:630
本文介绍了SFSafariViewController-从网页与父应用程序进行交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试研究一种将Web View Controller加载到iOS应用中的方法,以使网页可以将数据传递回父级.

使用SFSafariViewController可以吗?是否有类似后消息传递的机制,可以让我将数据发送回本机应用程序?

注意:使用SFSafariViewController非常重要,因为我还需要Web视图才能与Safari保持/共享cookie.

解决方案

由于SFSafariViewControllers没有像UIWebView的所有其他其他实现那样被沙盒化,因此这意味着它们可以访问诸如cookie之类的私人信息.

为安全起见,随后将SFSafariViewController从应用程序的其余部分沙盒化.在它和您的应用之间进行通信的一种方法是通过自定义URL方案.

这样做的缺点是您需要控制Web服务,并为此目的实现一个API(但是,您实际上不应该能够访问cookie).

您可以按照此项目开始使用.

希望这会有所帮助,

利亚姆

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.

解决方案

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

这篇关于SFSafariViewController-从网页与父应用程序进行交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆