Handling Universal Links
Prepare your app to respond to an incoming universal link.
When a user activates a universal link, the system launches your app and sends it an
NSUserActivity object. Query this object to find out how your app launched and to decide what action to take.
To support universal links in your app, take the following steps:
Create a two-way association between your app and your website and specify the URLs that your app handles. See Enabling Universal Links.
Update your app delegate to respond when it receives an
NSUserActivity object with the
activityType set to
Update Your App Delegate to Respond
When the system opens your app as the result of a universal link, your app receives an
NSUserActivity object with an
activityType value of
NSUserActivityTypeBrowsingWeb. The activity object’s
webpageURL property contains the HTTP or HTTPS URL that the user accesses. Use
NSURLComponents APIs to extract the components of the URL. For a macOS example, see Listing 1. For an iOS and tvOS example, see Listing 2.