Skip to content
Dashboard

Usage

import Detour
let detourConfig = DetourConfig(
apiKey: "<YOUR_DETOUR_API_KEY>",
appID: "<YOUR_DETOUR_APP_ID>",
shouldUseClipboard: true,
linkProcessingMode: .all
)

Use resolveInitialLink once during cold start (UIApplicationDelegate flow):

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Detour.shared.resolveInitialLink(config: detourConfig, launchOptions: launchOptions) { result in
if let link = result.link {
// Navigate using link.route / link.pathname / link.params
}
}
return true
}

If you use scene lifecycle, call the overload with connectionOptions in scene(_:willConnectTo:options:).

If you want complete, runnable integration with AppDelegate + SwiftUI UI state, go to Examples.

func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
Task { @MainActor in
let result = await Detour.shared.processLink(url, config: detourConfig)
// handle result.link
}
return true
}
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else {
return false
}
Task { @MainActor in
let result = await Detour.shared.processLink(url, config: detourConfig)
// handle result.link
}
return true
}

processLink and resolveInitialLink return:

processed

Link processing finished.

link
Type DetourLink?

Helpers exposed on DetourResult:

  • route
  • pathname
  • params
  • linkType
  • linkURL

DetourConfig.linkProcessingMode controls which link sources are handled:

ValueUniversal linksDeferred linksCustom scheme links
.all (default)YesYesYes
.webOnlyYesYesNo
.deferredOnlyNoYesNo

Use .deferredOnly when runtime links are handled by your own routing layer and Detour should resolve only deferred links.

resolveInitialLink(...) mounts analytics automatically.

You can also mount explicitly:

Detour.shared.mountAnalytics(config: detourConfig)

Emit events from app code:

DetourAnalytics.logEvent(.addToCart, data: ["sku": "abc"])
DetourAnalytics.logEvent("promo_banner_tap", data: ["placement": "home_top"])
DetourAnalytics.logRetention("day_7_return")