An object that provides a visible standard interface for browsing the web.


@interface SFSafariViewController : UIViewController


The view controller includes Safari features such as Reader, AutoFill, Fraudulent Website Detection, and content blocking. In iOS 9 and 10, it shares cookies and other website data with Safari. The user's activity and interaction with SFSafariViewController are not visible to your app, which cannot access AutoFill data, browsing history, or website data. You do not need to secure data between your app and Safari. If you would like to share data between your app and Safari in iOS 11 and later, so it is easier for a user to log in only one time, use SFAuthenticationSession instead.

UI features include the following:

  • A read-only address field with a security indicator and a Reader button

  • An Action button that invokes an activity view controller offering custom services from your app, and activities, such as messaging, from the system and other extensions

  • A Done button, back and forward navigation buttons, and a button to open the page directly in Safari

  • On devices that support 3D Touch, automatic Peek and Pop for links and detected data

To learn about 3D Touch, see 3D Touch in iOS Human Interface Guidelines and Adopting 3D Touch on iPhone.

Choosing the Best Web Viewing Class

If your app lets users view websites from anywhere on the Internet, use the SFSafariViewController class. If your app customizes, interacts with, or controls the display of web content, use the WKWebView class.

When you adopt SFSafariViewController and a user presses a link to peek at and then pop to the link’s destination, the user views web content from within your app. Tapping Done, the user returns to the view controller that was displayed before the web content was loaded. When you instead use the WKWebView class, Peek and Pop sends the user to Safari by default.


Creating a View Controller

- initWithURL:configuration:

Initializes and configures a Safari view controller that loads the specified URL.


A configuration object that defines how a Safari view controller should be initialized.

- initWithURL:

Initializes a Safari view controller that loads the specified URL.

- initWithURL:entersReaderIfAvailable:

Initializes a Safari view controller that will load the specified URL, entering Reader mode if Reader mode is requested and available.


Responding to View Controller Interaction


An object that provides behavior for the Safari view controller's Done and Action buttons.


A protocol used to implement custom event handling for a Safari view controller.

Configuring the View Controller


A copy of the Safari view controller’s initialized configuration.


The color to tint the background of the navigation bar and the toolbar.


The color to tint the control buttons on the navigation bar and the toolbar.


Inherits From

See Also

Safari Content in Your App


The completion handler for an authentication session when the user cancels or finishes the login.


A class that manages sharing a one-time login between Safari and an app, which can also be used for automatic login for associated apps.