iOS Setup

Deep Links

Many of the resources in the Rover SDK can be navigated to via "deep link". A Rover deep link is comprised of a scheme, a path and optional parameters. An example of a Rover deep link that presents an experience might look like: rv-myapp://myapp.rover.io/my-great-experience.

In this example rv-myapp is the scheme.


Initialize Rover

Each Rover account has a unique URL scheme that is used to construct Rover deep link URLs that map to your application. You can find the URL scheme assigned to your Rover account in the Rover Settings app.

The Rover SDK needs to know the URL scheme associated with your account. When you initialize Rover, set the urlSchemes property of the UIAssembler to include the URL scheme found in the Settings app.

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

Prepare Your App

In order for iOS to associate Rover deep link URLs with your app, you must add your Rover assigned URL scheme to your app's info.plist file.

Select your app's info.plist from the project navigator and click the plus (+) icon next to "Information Property List" to add a new property. Start typing "URL types" and press return (twice) when the proper suggestion is highlighted.

Now click the triangle icon beside the "URL types" property you just created to expand the array. Click the same triangle icon next to "Item 0" to expose the "URL identifier" property. In the value column enter a unique name for your scheme. A suggested convention is to append "rover" to the reverse of your domain. E.g. "com.example.rover".

Next click the plus (+) icon next to the "Item 0" row to add a new property to it and name it "URL Schemes".

Finally, click the triangle icon beside the "URL Schemes" property you just created to expose the "Item 0" row in the array and paste the value of the URL scheme assigned to your Rover account that you found in the Rover Settings app.


When a user taps a link with a URL scheme associated with your app, you need to forward the URL to Rover's Router service so it can delegate to the appropriate Rover module. The handle(_:) method returns a boolean indicating whether Rover handled the link, which you can use to apply your own custom logic for non-Rover URLs.

Always Call Rover's Router

Every link handling path in your app must call Rover.shared.router.handle(url). If you add custom logic that intercepts links before passing them to Rover, make sure Rover's router is still called. Otherwise, Rover links will silently fail to open.

SwiftUI

Handle this in your app scene with the onOpenURL(perform:) view modifier:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            RootView()
                .onOpenURL { url in
                    if !Rover.shared.router.handle(url) {
                        // Handle non-Rover URLs here.
                    }
                }
        }
    }
}

UIKit App Delegate

Forward the URL from application(_:open:options:) on your app delegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    if Rover.shared.router.handle(url) {
        return true
    }
    // Handle non-Rover URLs here.
    return false
}

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
Install