RTN Docs

iOS SDK · Preview

API reference

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

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.

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(writeKey: String, configuration: RTNConfiguration = .init())

Starts the SDK. Call it once at launch.

RTN.version: String

The SDK version, for example 0.1.0.

Configuration

OptionDefaultDescription
consent.grantedInitial analytics decision: .granted, .denied or .pending.
trackLifecycleEventstrueSends app_installed, app_updated, app_opened and app_backgrounded.
trackScreensfalseSends screen_viewed for every UIKit view controller that appears.
trackDeepLinkstrueSends deep_link_opened for links passed to handleOpenURL or continueUserActivity.
collectAdvertisingIdfalseReads the IDFA when tracking is authorized and the advertising purpose is granted.
childDirectedfalseDisables advertising identifiers and probabilistic attribution.
flushAt20Sends a batch once this many events are queued.
flushInterval.seconds(30)Sends queued events at least this often.
debugfalseLogs dropped calls and validation problems with os_log.

RTN.setConsent(_ state: RTNConsentState)

Sets the analytics decision to granted, denied or pending.

RTN.setConsentPurpose(_ purpose: RTNConsentPurpose, _ state: RTNConsentState) / RTN.getConsentPurpose(_ purpose: RTNConsentPurpose) -> RTNConsentState

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: [String: Any] = [:]) / RTN.identify(traits: [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.anonymousId: String? / RTN.installId: String?

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

Events

RTN.track(_ event: String, properties: [String: Any] = [:])

Records a custom event. event must be lowercase snake_case.

RTN.screen(_ name: String, properties: [String: Any] = [:])

Records a screen_viewed event with screen_name.

RTN.register(_ properties: [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? = nil)
  • RTN.productRemovedFromCart(_ product: RTNProduct, cartId: String? = nil)
  • RTN.cartViewed(_ cart: RTNCart)
  • RTN.checkoutStarted(_ cart: RTNCart)
  • RTN.orderCompleted(_ order: RTNOrder)
  • RTN.signedUp(method: String? = nil)
  • RTN.loggedIn(method: String? = nil)
  • RTN.searched(_ query: String)

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

RTN.getAttribution() -> RTNAttribution?

Returns the local attribution snapshot, or null without consent.

RTN.waitForAttribution(timeout: Duration = .seconds(2)) async -> RTNAttribution?

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

RTN.handleOpenURL(_ url: URL) -> Bool / RTN.continueUserActivity(_ activity: NSUserActivity) -> Bool

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

RTN.setPushToken(_ fcmToken: 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 nil when the user turns notifications off. Add the project's Firebase service account key under Flows → Channels in the dashboard. Use the token from Messaging.messaging().token (Firebase), not the raw APNs device token: RTN sends iOS pushes through FCM.

RTN.trackPushOpened(_ userInfo: [AnyHashable: Any]) -> URL?

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

RTN.flush() async

Immediately attempts to send queued events.

Platform-specific

RTN.requestTrackingAuthorization() async -> ATTrackingManager.AuthorizationStatus

Shows the App Tracking Transparency prompt and returns the result. The IDFA is collected only when this returns .authorized and the advertising purpose is granted.

View.rtnScreen(_ name: String, properties: [String: Any] = [:])

SwiftUI modifier that sends screen_viewed when the view appears.

On this page