我目前正在集成一个安全的登录提供商,他们的软件开发工具包使用模式SFSafariView打开一个登录页面。
-因为这不是标准的,所以SDK不能处理它。
除非用户强制点击链接并选择在我们的应用程序中打开,否则链接将继续显示在SFSafariView中的网页。
问:我怎样才能让显示在SFSafariView中的html网页上的链接被发送到它打开的同一个应用程序。注意-应用程序有相关的域名,并在网站上正确设置了AASA文件
有用的代码
//Sets up a SFSafariVC (use this code in a button to open a local html file with your link in)
guard let path = Bundle.main.path(forResource: "", ofType: "html") else { return }
let url = URL(fileURLWithPath: path)
let config = SFSafariViewController.Configuration()
let vc = SFSafariViewController(url: url, configuration: config)
present(vc, animated: true)发布于 2020-10-23 16:20:40
使用老式的deeplinks确实解决了我的问题。
通过注册自定义URL协议
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.appName.app</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appNameWebProtocol</string>
</array>
</dict>
</array>然后,使用appNameWebProtocol:// link /destination形式的链接,SFSafariViewController始终将此链接传递给应用程序。
这是由appDelegate方法拾取的
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
}此解决方案的问题-在我们的特定情况下,此链接将在网站上找到,该网站可以在应用程序外部查看,并且无需安装。如果是这种情况,链接将不会做任何事情,所以我们的解决方案必须在网页上包含自定义脚本,以确定它应该在webPage中显示哪个链接。
https://stackoverflow.com/questions/64491270
复制相似问题