Index of every page on this site: llms.txt
All skills
software-mansion-labs avatar

/migrate-to-detour

@43cde80
Run it yourself

Use when the user mentions migrating deep links, switching away from Branch or AppsFlyer, replacing their deep linking SDK, setting up Detour deep linking for the first time, or asks how Branch/AppsFlyer concepts map to Detour. Covers the complete migration end to end - Detour Dashboard configuration, Universal Links and App Links setup, SDK swap with code examples, and analytics migration. Works across Android, iOS, React Native, and Flutter.

Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/migrate-to-detour

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesios.md

≈2.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

iOS — Branch / AppsFlyer → Detour

Contents

  • Universal Links
  • SDK Installation
  • SDK Initialization & Deep Link Handling
  • Deferred Deep Links (First Install)
  • Analytics
  • Keeping this reference current

Universal Links

Before (Branch)

Associated Domains entitlement:

applinks:yourapp.app.link
applinks:yourapp-alternate.app.link

Before (AppsFlyer)

applinks:yourapp.onelink.me

After (Detour)

Replace with your Detour organization subdomain. Detour auto-hosts /.well-known/apple-app-site-association — no server setup needed.

Step 1 — Xcode → Signing & Capabilities → Associated Domains:

applinks:YOUR_ORG.godetour.link

Or via Expo config:

{
  "expo": {
    "ios": {
      "associatedDomains": ["applinks:YOUR_ORG.godetour.link"]
    }
  }
}

Step 2 — App Store Connect → Associated Domains capability:

Universal Links also require the capability to be enabled in App Store Connect, not just in Xcode. Without this step, links will work in local debug builds but fail on TestFlight and App Store.

  1. Go to App Store Connect → Certificates, Identifiers & Profiles
  2. Select your App ID → Edit
  3. Under Capabilities, enable Associated Domains
  4. Save — this triggers a new provisioning profile. Re-download and install it in Xcode.

If you use Xcode's automatic signing, this step may happen automatically when you add the entitlement. Verify the capability is listed as Enabled in App Store Connect regardless.

Info.plist — Custom URI Scheme (optional):

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>yourapp</string>
        </array>
    </dict>
</array>

SDK Installation

Swift Package Manager — Xcode → File → Add Package Dependencies:

https://github.com/software-mansion-labs/ios-detour

Or in Package.swift:

// Pin the current release — check the GitHub releases page / README for the latest version.
.package(url: "https://github.com/software-mansion-labs/ios-detour", from: "LATEST_VERSION")

Remove the Branch or AppsFlyer package.


SDK Initialization & Deep Link Handling

Before (Branch)

// AppDelegate.swift
import Branch

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Branch.getInstance().initSession(launchOptions: launchOptions) { params, error in
        guard error == nil, let params = params as? [String: AnyObject] else { return }
        let canonicalUrl = params["$canonical_url"] as? String
        // navigate to canonicalUrl
    }
    return true
}

func application(_ app: UIApplication, open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    Branch.getInstance().application(app, open: url, options: options)
    return true
}

func application(_ application: UIApplication,
                 continue userActivity: NSUserActivity,
                 restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    Branch.getInstance().continue(userActivity)
    return true
}

Before (AppsFlyer)

// AppDelegate.swift
import AppsFlyerLib

class AppDelegate: UIResponder, UIApplicationDelegate, AppsFlyerLibDelegate, DeepLinkDelegate {

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        AppsFlyerLib.shared().appsFlyerDevKey = "YOUR_AF_DEV_KEY"
        AppsFlyerLib.shared().appleAppID = "YOUR_APPLE_APP_ID"
        AppsFlyerLib.shared().delegate = self
        AppsFlyerLib.shared().deepLinkDelegate = self
        AppsFlyerLib.shared().start()
        return true
    }

    // Deferred deep link (first install)
    func onConversionDataSuccess(_ conversionInfo: [AnyHashable: Any]) {
        guard let isFirstLaunch = conversionInfo["is_first_launch"] as? Bool, isFirstLaunch else { return }
        let deepLinkValue = conversionInfo["deep_link_value"] as? String
        // navigate to deepLinkValue
    }

    // Direct deep link — UDL API
    func didResolveDeepLink(_ deepLinkResult: DeepLinkResult) {
        guard deepLinkResult.status == .found else { return }
        let deepLinkValue = deepLinkResult.deepLink?.deepLinkValue
        // navigate to deepLinkValue
    }

    func application(_ app: UIApplication, open url: URL,
                     options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        AppsFlyerLib.shared().handleOpen(url, options: options)
        return true
    }

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

After (Detour)

// AppDelegate.swift
import Detour

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    let detourConfig = DetourConfig(
        apiKey: "YOUR_API_KEY",    // Detour Dashboard → API Configuration
        appID: "YOUR_APP_ID",      // Detour Dashboard → API Configuration
        shouldUseClipboard: true   // improves deferred link matching on iOS
    )

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Detour.shared.mountAnalytics(config: detourConfig)

        // Handles both deferred and direct links on cold start
        Detour.shared.resolveInitialLink(config: detourConfig, launchOptions: launchOptions) { result in
            self.handleLink(result)
        }
        return true
    }

    // Custom URI scheme (yourapp://...)
    func application(_ app: UIApplication, open url: URL,
                     options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        Task { @MainActor in
            let result = await Detour.shared.processLink(url, config: self.detourConfig)
            self.handleLink(result)
        }
        return true
    }

    // Universal Link (https://YOUR_ORG.godetour.link/...)
    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: self.detourConfig)
            self.handleLink(result)
        }
        return true
    }

    private func handleLink(_ result: DetourResult) {
        guard let link = result.link else { return }

        // link.type:
        //   .deferred — user clicked link before installing
        //   .verified — Universal Link (domain verified)
        //   .scheme   — custom URI scheme
        //
        // link.route    — e.g. "/products/123?color=red"
        // link.pathname — e.g. "/products/123"
        // link.params   — e.g. ["color": "red"]

        NotificationCenter.default.post(name: .detourLinkReceived, object: link)
    }
}

SwiftUI / SceneDelegate apps:

// SceneDelegate.swift
func scene(_ scene: UIScene,
           willConnectTo session: UISceneSession,
           options connectionOptions: UIScene.ConnectionOptions) {
    Detour.shared.resolveInitialLink(
        config: detourConfig,
        connectionOptions: connectionOptions
    ) { result in
        self.handleLink(result)
    }
}

Deferred Deep Links (First Install)

Branch's initSession and AppsFlyer's onConversionDataSuccess had separate deferred-link paths.

With Detour, resolveInitialLink handles both. Check link.type == .deferred:

Detour.shared.resolveInitialLink(config: detourConfig, launchOptions: launchOptions) { result in
    guard let link = result.link else { return }
    if link.type == .deferred {
        // First install — user clicked a Detour link before installing the app
    }
    // navigate using link.route regardless of type
}

For testing, reset the first-launch flag:

Detour.shared.resetSession(allowDeferredRetry: true)

Analytics

Event mapping

Branch (BranchEvent) AppsFlyer Detour (DetourEventName)
.purchase AFEventPurchase .purchase
.addToCart AFEventAddToCart .addToCart
.removeFromCart — .removeFromCart
.viewItem AFEventContentView .viewItem
.initiatePurchase AFEventInitiatedCheckout .beginCheckout
.addPaymentInfo AFEventAddPaymentInfo .addPaymentInfo
.login AFEventLogin .login
.completeRegistration AFEventCompleteRegistration .signUp
.search AFEventSearch .search
.share AFEventShare .share
.invite — .invite
custom event name custom event name logRetention("name") (no enum entry — see below)

Before (Branch)

let event = BranchEvent.standardEvent(.purchase)
event.revenue = 29.99
event.currency = BNCCurrency.USD
event.customData = ["product_id": "abc123"]
event.logEvent()

Before (AppsFlyer)

AppsFlyerLib.shared().logEvent(
    AFEventPurchase,
    withValues: [
        AFEventParamRevenue: 29.99,
        AFEventParamCurrency: "USD",
        "product_id": "abc123"
    ]
)

After (Detour)

DetourAnalytics.logEvent(.purchase, data: [
    "revenue": 29.99,
    "currency": "USD",
    "product_id": "abc123"
])

Custom / non-standard events — logEvent accepts only DetourEventName enum values; a custom name must use logRetention, which takes only a name (no data payload):

DetourAnalytics.logRetention("promo_banner_tapped")

Retention / session events:

DetourAnalytics.logRetention("app_open")

Keeping this reference current

If the user asks about the latest version, installation steps, or you suspect anything above may be outdated, fetch the live README:

https://github.com/software-mansion-labs/ios-detour/blob/main/README.md

Cross-reference against the sections above and prefer the live README if they conflict.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning4mo3 checks · Risk SAFE
  • Gen Agent Trust Hub4mo

    This skill acts as a migration assistant to help developers transition mobile applications from Branch or AppsFlyer to the Detour deep-linking SDK. It provides comprehensive, step-by-step instructions and code examples for Android, iOS, React Native, and Flutter. The analysis confirms that the skill is safe, follows security best practices for credential management, and only references legitimate vendor-owned resources.

  • Socket4mo

    No alerts

  • Snyk4mo

    Risk: MEDIUM · 2 issues

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 5 months ago

README badge

README badge for software-mansion-labs/skills/migrate-to-detour