Implement SFSafariViewControllerDelegate

suggest change

You should implement SFSafariViewControllerDelegate so that your class is notified when the user hits the Done button on the SafariViewController and you can dismiss it as well.

First declare your class to implement the protocol.

class MyClass: SFSafariViewControllerDelegate {

}

Implement the delegate method to be notified on dismissal.

func safariViewControllerDidFinish(controller: SFSafariViewController) {
    // Dismiss the SafariViewController when done
    controller.dismissViewControllerAnimated(true, completion: nil)
}

Don’t forget to set your class as the SafariViewController’s delegate.

let safariVC = SFSafariViewController(URL: yourURL)
safariVC.delegate = self

Additional delegate methods you can implement are:

// Called when the initial URL load is complete.
safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) { }

// Called when the user taps an Action button.
safariViewController(_ controller: SFSafariViewController, activityItemsFor URL: URL, title: String?) -> [UIActivity] { }

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Safari Services:
* Implement SFSafariViewControllerDelegate

Table Of Contents
12 UIView
15 UIColor
24 Safari Services
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
49 NSTimer
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable