Skip to main content
The React Native and Expo SDK records installs, sessions, screens and your own events, and links each install to the RevenueCat customer. Events are queued on the device and sent in batches. They survive offline periods and app restarts.

Install

Config plugin

The plugin adds NSAdvertisingAttributionReportEndpoint and AdAttributionKit › AttributionCopyEndpoint to Info.plist, so iOS sends copies of winning SKAdNetwork and AdAttributionKit postbacks to Appeeky.
An app can name only one endpoint. See SKAdNetwork.

Native module

The package includes a native module (Expo Modules). It needs a development build or a release build. Without the native module (Expo Go, or a plain React Native app without Expo Modules) the SDK still runs in JavaScript. Events, screens, sessions, identify and campaign links keep working. Apple Search Ads attribution, the Play referrer and conversion values turn off, unless you pass getAdServicesToken and getInstallReferrer yourself (see Options).

Methods

init(options)

Starts the SDK. Call it once, as early as possible.
A second call returns the existing instance and ignores the new options. Other methods called before init are ignored (with a warning in development).

identify(userId)

Links the install to a RevenueCat app user id, so purchases get the install’s source.
The id is sent with every batch from then on, and the SDK sends a batch soon after identify so the install is linked before the first purchase. Ids are cut to 256 characters.

screen(name, props?)

Records a screen view.
Screen names are cut to 128 characters. Screens are used by the screen, entry screen and exit screen breakdowns, by funnel steps like screen:Paywall, and by the purchase journey in sale alerts.

track(name, props?, value?)

Records a custom event, with optional properties and an optional number.
  • Event names may use letters, digits, _, ., : and -, up to 64 characters.
  • Property values are strings (up to 512 characters), numbers, booleans or null. All properties of one event together must stay under 4 KB.
Custom events can be funnel steps. Revenue does not come from track: use RevenueCat for purchases and adRevenue for ads.

adRevenue(valueUsd, details?)

Records ad revenue from one paid impression, in USD. It counts as revenue for the install’s source, next to RevenueCat purchases.
The value must already be in USD. The SDK does not convert currencies. Skip impressions reported in another currency, as in the example.
Returns the in-app destination of the smart link that brought this install, once, on the first launch. Returns null afterwards, or when there is none.
On Android, the destination comes from the Play install referrer, so it works after a fresh install from Google Play. On iOS, it is only set when a smart link opened the already-installed app on its first launch. See Smart Links.

trialStarted()

Raises the SKAdNetwork / AdAttributionKit conversion value to “trial started”. Call it when a trial starts.

purchased(valueUsd)

Raises the conversion value to the purchase bucket for this amount in USD. Call it after a purchase succeeds.
trialStarted and purchased only update the conversion value on iOS. Revenue itself comes from RevenueCat, so nothing is counted twice. See SKAdNetwork for the value schema.

flush()

Sends queued events now. Returns a promise.

shutdown()

Stops timers and app state listeners. Use it in tests, or before calling init again with a different key.

Options

Without the native module, you can supply the attribution callbacks yourself:
Attribution is collected once, on the first launch. Each callback has 3 seconds to answer.

Automatic Events

Sale events (trial_started, purchase, trial_converted, renewal, refund) do not come from the SDK. They come from RevenueCat. See Revenue. The first time the app is opened, the SDK also reads the URL it was opened with (Linking.getInitialURL()) to detect campaign links.

Sending and Retries

  • Events are queued in AsyncStorage and sent in batches of up to 100.
  • A batch is sent every flushIntervalMs, when flushAt events are queued, and when the app goes to the background.
  • If the server is busy or the device is offline, the SDK keeps the batch and retries later. Each event has an id, so a retried batch is never counted twice.
  • The server drops events older than 30 days, more than 10 minutes in the future (a wrong device clock or a very old offline queue), or with properties over 4 KB. The rest of the batch is kept.