11

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
}
jtbandes
  • 115,675
  • 35
  • 233
  • 266
Ashish Verma
  • 113
  • 1
  • 5
  • Up-voted question. Now, do you have **any** examples where this is possible? (I haven't used SFSafariViewController in anything - personal or professional - since Swift 2. Can this be done?) –  Dec 27 '16 at 17:07
  • I did Answer That Check My Answer [Here](https://stackoverflow.com/a/62280728/9403403) – abdallah Nader Jun 09 '20 at 11:03

1 Answers1

4

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

an23lm
  • 376
  • 2
  • 15