RTN Docs

Flutter SDK · Preview

API reference

Every planned method of the RTN Flutter SDK with its signature and behavior.

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.

Public methods never throw. Invalid input is ignored and reported when debug is on. Method names match the Web SDK wherever the platform allows.

Setup

Future<void> Rtn.initialize(String writeKey, {RtnConfig config = const RtnConfig()})

Starts the SDK. Call it once at launch.

Future<String> Rtn.version

The SDK version, for example 0.1.0.

Configuration

OptionDefaultDescription
consentConsentState.grantedInitial analytics decision: granted, denied or pending.
trackLifecycleEventstrueSends app_installed, app_updated, app_opened and app_backgrounded.
trackDeepLinkstrueSends deep_link_opened for links received by the native layer.
collectAdvertisingIdfalseReads the platform advertising ID under the native consent rules.
childDirectedfalseDisables advertising identifiers and probabilistic attribution.
flushAt20Sends a batch once this many events are queued.
flushIntervalDuration(seconds: 30)Sends queued events at least this often.
debugfalseLogs dropped calls and validation problems.

Future<void> Rtn.setConsent(ConsentState state)

Sets the analytics decision to granted, denied or pending.

Future<void> Rtn.setConsentPurpose(ConsentPurpose purpose, ConsentState state) / Future<ConsentState> Rtn.getConsentPurpose(ConsentPurpose purpose)

Manages a purpose-level decision. See Consent and privacy for purposes.

Future<void> Rtn.pause() / Future<void> Rtn.resume()

Stops and restarts collection and delivery without deleting identities or queued events. Calls made while paused are dropped.

Identity

Future<void> Rtn.identify(String userId, {Map<String, Object?> traits = const {}}) / Future<void> Rtn.identifyTraits(Map<String, Object?> traits)

Associates events with a known customer. For a guest without a customer ID, pass only traits with email or phone.

Future<void> Rtn.reset()

Clears the known customer and starts a new anonymous identity. Call it at sign-out.

Future<String?> Rtn.getAnonymousId() / Future<String?> Rtn.getInstallId()

The device anonymous ID and the install ID assigned by RTN, or null without consent.

Events

void Rtn.track(String event, [Map<String, Object?> properties = const {}])

Records a custom event. event must be lowercase snake_case.

void Rtn.screen(String name, [Map<String, Object?> properties = const {}])

Records a screen_viewed event with screen_name.

void Rtn.register(Map<String, Object?> properties) / void Rtn.unregister(String key)

Adds or removes properties attached to every following event.

Ecommerce helpers

  • void Rtn.productViewed(RtnProduct product)
  • void Rtn.productAddedToCart(RtnProduct product, {String? cartId})
  • void Rtn.productRemovedFromCart(RtnProduct product, {String? cartId})
  • void Rtn.cartViewed(RtnCart cart)
  • void Rtn.checkoutStarted(RtnCart cart)
  • void Rtn.orderCompleted(RtnOrder order)
  • void Rtn.signedUp([String? method])
  • void Rtn.loggedIn([String? method])
  • void Rtn.searched(String query)

See Events and identity and the Web SDK Ecommerce Events page for fields.

Future<RtnAttribution?> Rtn.getAttribution()

Returns the local attribution snapshot, or null without consent.

Future<RtnAttribution?> Rtn.waitForAttribution({Duration timeout = const Duration(seconds: 2)})

Resolves with server-confirmed install attribution, or with the local snapshot after the timeout.

Future<bool> Rtn.handleDeepLink(Uri url)

Records deep_link_opened for an incoming link and forwards it to onDeepLink listeners. Returns whether the link was handled.

Registers a listener for direct and deferred deep links. Unsubscribe when the listener is no longer needed.

Push

Future<void> Rtn.setPushToken(String? token)

Registers the device's Firebase Cloud Messaging token so flows can send it app pushes (POST /v1/mobile/push-tokens). Call it on every app start and whenever Firebase refreshes the token; pass null when the user turns notifications off. Add the project's Firebase service account key under Flows → Channels in the dashboard. Use the token from firebase_messaging (getToken() and onTokenRefresh).

String? Rtn.trackPushOpened(Map<String, Object?> data)

Records push_opened for a notification RTN sent and returns the link it should open. RTN pushes carry rtn_message_id and url in their data payload; url is a tracked link, so opening it also counts the tap as a click in flow reports.

Delivery

Future<void> Rtn.flush()

Immediately attempts to send queued events.

Platform-specific

Future<TrackingAuthorization> Rtn.requestTrackingAuthorization()

Shows the App Tracking Transparency prompt on iOS. Returns authorized immediately on Android.

RtnNavigatorObserver()

A NavigatorObserver that sends screen_viewed for every named route.

On this page