SDK
React Native SDK
Add creator install attribution and promo-code offers with @tapapplink/react-native. The same package works in Expo development clients and production builds, and in bare React Native. Use a development build; Expo Go cannot load Play Install Referrer.
Prerequisites
- React Native 0.70 or later, or Expo with a custom dev client
- A Tap App Link app with an SDK key from Quick start
1. Install
yarn add @tapapplink/react-nativeRebuild the native app. Bare iOS apps should run cd ios && pod install after installing. The Android package includes a small Play Install Referrer module. Rebuild the native app after installing. A JS-only reload does not include that native module.
2. Configure, track, identify
Call this from the app entry point. Replace the key with the one from SDK Setup. Use sandbox on test builds.
import { TapAppLink } from "@tapapplink/react-native";
import Purchases from "react-native-purchases";
TapAppLink.configure({
publicKey: "YOUR_TAPAPPLINK_KEY",
environment: __DEV__ ? "sandbox" : "production",
});
await TapAppLink.trackInstall();
await TapAppLink.setAppUserId(await Purchases.getAppUserID());
const offer = TapAppLink.getOffer();
if (offer?.billingOfferId) {
const offerings = await Purchases.getOfferings();
const discounted = offerings.all[offer.billingOfferId];
// Present this offering on the paywall
}3. Discount codes
After a match, getOffer() returns the creator discount. When someone types a code in-app, call applyCode() so they still attribute. Purchases then arrive through billing webhooks.
await TapAppLink.applyCode("SARAH10");
const offer = TapAppLink.getOffer();SDK reference
| Method | Purpose |
|---|---|
configure | Set public key, environment, optional ingest URL. |
trackInstall() | First open. Matches a recent click in this environment. |
setAppUserId(id) | Bridge the billing customer id for webhooks. |
getOffer() | Creator discount after a match or redeem. |
applyCode(code) | Attribute from a promo code typed at checkout. |
resetForTesting() | Clear cached install state in debug builds. |
Important notes
trackInstall()is safe on every launch. It only records once per install.- Call
resetForTesting()in debug builds before repeating a match test on the same install. - Purchases are attributed through billing webhooks. Do not add a client
trackPurchase()call. - After a match or
applyCode(), presentgetOffer()on the paywall. Discount codes.