Instance Property

allowsLinkPreview

A Boolean value that determines whether pressing on a link displays a preview of the destination for the link.

Declaration

var allowsLinkPreview: Bool { get set }

Discussion

In iOS this property is available on devices that support 3D Touch. Default value is false in iOS.

If you set this property’s value to true, an iOS user can press links to preview link destinations and detected data such as addresses and phone numbers. Such previews are known to users as peeks. If a user presses deeper on a link preview, the preview navigates (or pops, in user terminology) to the destination. Because pop navigation switches the user from your app to Safari, it is opt-in for iOS apps.

If you want to support link preview in iOS but also want to keep users within your app, you can switch from using the WKWebView class to the SFSafariViewController class. If you are using a web view as an in-app browser, making this change is best practice. The Safari view controller class automatically supports link previews.

In macOS this property is available on devices with a Force Touch trackpad. Default value is true in macOS.

With this property set to its default value of true, a macOS user can force click a link to display a preview window showing the link’s destination. If the user then clicks on the preview, the destination opens in Safari.

On both platforms, all types of detected data respond to presses when this property is set to true. That is, in iOS 9 and OS X v10.11, you cannot specify which types of data are detected in the WKWebView class.