iOS Setup

Universal Links

Universal Links is a feature of iOS that allows seamless linking of content that can be accessed through both a browser and within your app. Rover supports Universal Links for presenting Experiences.

An example of a universal Experience URL might look like https://myapp.rover.io/my-great-experience. When a user opens this URL on a mobile device it will present the Experience directly in your app. If the user doesn't have your app installed it will fall-back to viewing the web-based version of the Experience in the browser.


Initialize Rover

Similar to the URL scheme used by Rover's Deep Links setup, each Rover account has a unique domain that is used to construct Rover universal links. You can find the domain assigned to your Rover account in the Rover Settings app scrolling down from the general settings to the associated domain.

Settings App

Also similar to Deep Links, the Rover SDK needs to know the domain associated with your account. When you initialize Rover, set the associatedDomains property of the UIAssembler to include the domain found in the Settings app.

Rover.initialize(assemblers: [
    FoundationAssembler(),
    DataAssembler(accountToken: "YOUR_SDK_TOKEN"),
    UIAssembler(associatedDomains: ["myapp.rover.io"], urlSchemes: ["rv-myapp"]),
    ExperiencesAssembler(),
    NotificationsAssembler(),
    LocationAssembler(),
    DebugAssembler()
])

Prepare Your App

In order for the domain assigned to your Rover account to be associated with your app, you need to add the Associated Domains feature to your App ID and add your Rover domain to the list of associated domains in the entitlement. This can be done directly from within Xcode. Open your Xcode project or workspace and select your app from the Project Navigator. Then select your app's target and the "Signing & Capabilities" tab. Then press the "+ Capability" button.

Xcode Capabilities Tab

Then select "Associated Domains" from the dialog. This will add the capability. Add your Rover domain prefixed with applinks: to the list of associated domains.

applinks


Site Association

Before iOS will open URLs with an associated domain, it needs to verify permssion from the domain owner. It does by checking for the presence of a special file named apple-app-site-association uploaded to the domain's web server. Rover will create this file for you and serve it at your associated domain but you need to provide your App ID Prefix and App Store ID which is used in the file's contents.

Note: To learn more about site association read the Support Universal Links guide on Apple's Developer Center.

App ID Prefix

To find your App ID Prefix, sign-in to the Apple Developer Centre and click on "Certificates, Identifiers & Profiles".

Developer Portal

Click on "App IDs" in the sidebar, and find your App ID in the list.

App IDs

Click on your App ID and you will see a value labelled "Prefix".

Prefix

App Store ID

To find your App Store ID visit the iTunes Link Maker. Select the appropriate country and change the media type to "iOS Apps". Now type the name of your app in the search field and submit.

Link Maker

In the results, click on your app and you will see a "Direct Link" on the bottom of the page. Your App Store ID is the nine-digit number in between id and ?mt.

App Store ID

iOS Settings

Visit the Settings page of the Rover Settings app. Click on the "Link Configuration" heading, then fill in the Team ID and Bundle ID.

Enter Settings

Note: If you've already setup APNs, the Bundle Identifier field will be filled in for you. If not, you will need to fill that field in as well.

Save the form and verify the apple-app-site-association file is available in the .well-known directory of your Rover associated domain.

Example: https://myapp.rover.io/.well-known/apple-app-site-association.


When a user taps a link with a domain that is associated with your app, iOS calls the application(_:continue:restorationHandler:) method. The URL of the link that was tapped is contained within the userActivity argument. Rover's Router service can handle the userActivity by delegating to the appropriate Rover module. In order to do this, you can use Rover's Router service and by calling its handle(_:) method from with your app delegate's application(_:continue:restorationHandler:) method.

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    return Rover.shared.router.handle(userActivity)
}

Testing Universal Links

Universal Links are notoriously difficult to test. iOS will only verify the associated domain when a "production" release of your app is installed. Until that happens your Rover domain will not be associated with your app and Universal Links will not function. TestFlight does count as a "production" release and deploying a build through TestFlight may be a viable workaround.

Rover Routing and Threads

Only call Rover's router.handle() method from the main thread. Be aware that certain routing tools, such as Firebase, may call your handlers on background threads, so be sure to switch back to the main thread before calling Rover.

Previous
Deep Links