An object that provides a visible standard interface for browsing the web.
SDKs
- iOS 9.0+
- Mac Catalyst 13.0+
Framework
- Safari
Services
Declaration
class SFSafariViewController : UIView Controller
Overview
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 SFSafari
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 SFAuthentication
instead.
Important
In accordance with App Store Review Guidelines, this view controller must be used to visibly present information to users; the controller may not be hidden or obscured by other views or layers. Additionally, an app may not use SFSafari
to track users without their knowledge and consent.
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.
Note
For iPad apps running in macOS, SFSafari
launches the default web browser instead of displaying a modal window.
Choosing the Best Web Viewing Class
If your app lets users view websites from anywhere on the Internet, use the SFSafari
class. If your app customizes, interacts with, or controls the display of web content, use the WKWeb
class.
When you adopt SFSafari
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 WKWeb
class, Peek and Pop sends the user to Safari by default.