Android SDK · Preview
API reference
Every planned method of the RTN Android SDK with its signature and behavior.
Preview: planned API
The Android 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
RTN.initialize(context: Context, writeKey: String, config: RTNConfig = RTNConfig())
Starts the SDK. Call it once at launch.
RTN.version: String
The SDK version, for example 0.1.0.
Configuration
| Option | Default | Description |
|---|---|---|
consent | ConsentState.GRANTED | Initial analytics decision: GRANTED, DENIED or PENDING. |
trackLifecycleEvents | true | Sends app_installed, app_updated, app_opened and app_backgrounded. |
trackScreens | false | Sends screen_viewed for every resumed Activity. |
trackDeepLinks | true | Sends deep_link_opened for links passed to handleDeepLink. |
collectAdvertisingId | false | Reads the Google Advertising ID when the advertising purpose is granted. |
childDirected | false | Disables advertising identifiers and probabilistic attribution. |
flushAt | 20 | Sends a batch once this many events are queued. |
flushIntervalSeconds | 30 | Sends queued events at least this often. |
debug | false | Logs dropped calls and validation problems to Logcat. |
Consent
RTN.setConsent(state: ConsentState)
Sets the analytics decision to granted, denied or pending.
RTN.setConsentPurpose(purpose: ConsentPurpose, state: ConsentState) / RTN.getConsentPurpose(purpose: ConsentPurpose): ConsentState
Manages a purpose-level decision. See Consent and privacy for purposes.
RTN.pause() / RTN.resume()
Stops and restarts collection and delivery without deleting identities or queued events. Calls made while paused are dropped.
Identity
RTN.identify(userId: String, traits: Map<String, Any?> = emptyMap()) / RTN.identify(traits: Map<String, Any?>)
Associates events with a known customer. For a guest without a customer ID, pass only traits with email or phone.
RTN.reset()
Clears the known customer and starts a new anonymous identity. Call it at sign-out.
RTN.getAnonymousId(): String? / RTN.getInstallId(): String?
The device anonymous ID and the install ID assigned by RTN, or null without consent.
Events
RTN.track(event: String, properties: Map<String, Any?> = emptyMap())
Records a custom event. event must be lowercase snake_case.
RTN.screen(name: String, properties: Map<String, Any?> = emptyMap())
Records a screen_viewed event with screen_name.
RTN.register(properties: Map<String, Any?>) / RTN.unregister(key: String)
Adds or removes properties attached to every following event.
Ecommerce helpers
RTN.productViewed(product: RTNProduct)RTN.productAddedToCart(product: RTNProduct, cartId: String? = null)RTN.productRemovedFromCart(product: RTNProduct, cartId: String? = null)RTN.cartViewed(cart: RTNCart)RTN.checkoutStarted(cart: RTNCart)RTN.orderCompleted(order: RTNOrder)RTN.signedUp(method: String? = null)RTN.loggedIn(method: String? = null)RTN.searched(query: String)
See Events and identity and the Web SDK Ecommerce Events page for fields.
Attribution and deep links
RTN.getAttribution(): RTNAttribution?
Returns the local attribution snapshot, or null without consent.
suspend RTN.awaitAttribution(timeoutMillis: Long = 2_000): RTNAttribution?
Resolves with server-confirmed install attribution, or with the local snapshot after the timeout.
RTN.handleDeepLink(intent: Intent): Boolean
Records deep_link_opened for an incoming link and forwards it to onDeepLink listeners. Returns whether the link was handled.
RTN.onDeepLink(listener: (RTNDeepLink) -> Unit): Subscription
Registers a listener for direct and deferred deep links. Unsubscribe when the listener is no longer needed.
Push
RTN.setPushToken(token: String?)
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 FirebaseMessaging.getInstance().token and onNewToken.
RTN.trackPushOpened(extras: Bundle?): Uri?
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
suspend RTN.flush()
Immediately attempts to send queued events.