Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close SFSafariViewController automatically when reaching a certain page

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
}
like image 999
Ashish Verma Avatar asked Dec 27 '16 17:12

Ashish Verma


1 Answers

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().

like image 105
an23lm Avatar answered Nov 15 '22 21:11

an23lm