RTN Docs

Flutter SDK · Preview

Attribution and deep links

Attribute installs to campaigns, route direct and deferred deep links, and connect push notifications on Flutter.

Preview: planned API

The Flutter 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.

Install attribution comes from the native SDKs: the Play Install Referrer on Android, AdServices and the deferred deep link token on iOS.

// Resolves once the server has matched the install, or falls back
// to the local snapshot after the timeout.
final attribution = await Rtn.waitForAttribution(
  timeout: const Duration(seconds: 2),
);
debugPrint('${attribution?.network} ${attribution?.campaignId}');

// Local snapshot, or null without consent
final local = await 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.

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.

// Direct and deferred links, already parsed by the native layer
final subscription = Rtn.onDeepLink.listen((link) {
  // link.url, link.isDeferred, link.campaignId
  router.go(link.url.path);
});

// Links you receive yourself, for example from app_links
await Rtn.handleDeepLink(Uri.parse(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.

FirebaseMessaging.instance.onTokenRefresh.listen(Rtn.setPushToken);
Rtn.setPushToken(await FirebaseMessaging.instance.getToken());

FirebaseMessaging.onMessageOpenedApp.listen((message) {
  Rtn.trackPushOpened(message.data);
});

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.

await Rtn.flush();
await launchUrl(paymentUrl);

On this page