iOS SDK · Preview
Attribution and deep links
Attribute installs to campaigns, route direct and deferred deep links, and connect push notifications on iOS.
Preview: planned API
The iOS SDK is in development and not published yet. This page describes the API we are building so you can plan your integration. Package names, signatures and defaults may still change before the first release.
Install attribution
On the first launch the SDK sends an install with the signals the platform allows. The server matches it against clicks on RTN tracking links and ad engagements, checks it for fraud, and returns the winning source.
On iOS the SDK sends the Apple Search Ads (AdServices) token on first launch and, with tracking authorized, the IDFA. Clicks on RTN tracking links are matched deterministically through the deferred deep link token.
// Resolves once the server has matched the install, or falls back
// to the local snapshot after the timeout.
Task {
let attribution = await RTN.waitForAttribution(timeout: .seconds(2))
print(attribution?.network ?? "organic", attribution?.campaignId ?? "")
}
// Synchronous local snapshot, or nil without consent
let local = RTN.getAttribution()The attribution contains the network, campaign_id, click_id, matched_by (deterministic or probabilistic) and, when the click carried one, the deferred_deep_link. Probabilistic matching is used only when the probabilistic_attribution purpose is granted.
Deep links
Pass incoming links to the SDK so it can record deep_link_opened with campaign parameters. Register one listener for both direct links and deferred links, which arrive on the first launch after an install from an RTN tracking link.
WindowGroup {
ContentView()
.onOpenURL { url in
RTN.handleOpenURL(url)
}
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
RTN.continueUserActivity(activity)
}
}
// Direct and deferred links arrive here
RTN.onDeepLink { link in
// link.url, link.isDeferred, link.campaignId
router.open(link.url)
}Push notifications
Register the device push token so RTN journeys can reach the customer with push, and report opens so they count toward journey results.
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
RTN.setPushToken(deviceToken)
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse) async {
RTN.trackPushOpened(response.notification.request.content.userInfo)
}Send before leaving the app
Call flush before you hand the customer to another app, such as a payment provider, so the last events are not delayed until the next launch.
Task {
await RTN.flush()
openURL(paymentURL)
}