如何在到达某个页面时自动关闭SFSafariViewController [英] How to close SFSafariViewController automatically when reaching a certain page

查看:217
本文介绍了如何在到达某个页面时自动关闭SFSafariViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户上传内容后到达Dropbox网站的谢谢页面时自动关闭SFSafariViewController;它需要自动解雇。我怎样才能做到这一点?

I want to close SFSafariViewController automatically upon reaching the "thank you" page of the Dropbox site after the user uploads something; it needs to automatically dismiss. How can I do that?

这是我到目前为止所拥有的:

Here is what I have so far:

@IBAction func Singles5(_ sender: Any) {
    let safariVC = SFSafariViewController(url: NSURL(string: "https://www.dropbox/Upload")! as URL)
    self.present(safariVC, animated: true, completion: nil)
    safariVC.delegate = self
}


推荐答案

我能想到的一种方法是使用自定义网址方案。您可以在Dropbox的回调参数中指定应用的自定义网址(如果Dropbox具有回调功能)。因此,当用户完成上传他/她的文件后,dropbox会执行回调。在这种情况下,您的应用程序将收到回调,您指定了任何参数。这将在 AppDelegate 中调用函数应用程序(app,open,options) - > Bool 。现在,您可以使用 ViewController 的引用,该引用显示 SFSafariViewController 并调用 SafariViewController.dissmissViewController()

One way I can think of is using the Custom URL scheme. You can specify your app's custom URL in the callback parameter of Dropbox (if Dropbox has callback). So when the user has finished uploading his/her file, dropbox executes the callback. In this case your app will receive the callback, with any parameters have you specified. This will call the function application(app, open, options)->Bool in your AppDelegate. Now, you can use a reference to the ViewController which presents the SFSafariViewController and call SafariViewController.dissmissViewController().

这篇关于如何在到达某个页面时自动关闭SFSafariViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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