React Native SDK
One integration for iOS + Android. Pure JS/TS over fetch — no native modules to link.
Install
npm i @maa/sdk-react-native @react-native-async-storage/async-storageConfigure (once, at app startup)
The SDK needs a storage adapter to persist its device id and attribution — inject
AsyncStorage (or any object with getItem/setItem):
import AsyncStorage from "@react-native-async-storage/async-storage";
import { AffiliateSdk } from "@maa/sdk-react-native";
AffiliateSdk.configure({
apiKey: "pk_live_…", // your app's SDK key
baseUrl: "https://api.myappaffiliate.com",
storage: AsyncStorage,
});Attribute
Incoming link — wire up Linking and pass the URL through (the SDK extracts the
claim_token/ct param):
import { Linking } from "react-native";
Linking.getInitialURL().then((url) => url && AffiliateSdk.attribute(url));
Linking.addEventListener("url", ({ url }) => AffiliateSdk.attribute(url));Manual code (reliable everywhere — a creator's "LUMI"):
await AffiliateSdk.applyCode("LUMI");Identify the user
Use the same id you pass to RevenueCat (Purchases.logIn(...)):
await AffiliateSdk.identify(userId);Pass the affiliate into RevenueCat
Before the purchase, with react-native-purchases:
import Purchases from "react-native-purchases";
const aff = await AffiliateSdk.attributedAffiliateId();
if (aff) await Purchases.setAttributes({ affiliate_id: aff });Expo
Works in the managed workflow — the SDK is pure JS and AsyncStorage has an Expo
build (npx expo install @react-native-async-storage/async-storage). For deep links
use expo-linking's useURL() and feed the URL to AffiliateSdk.attribute(url).
Universal/App Links need a dev build or EAS (associated domains can't be tested in
Expo Go); the referral-code path works everywhere including Expo Go.
API
| Call | Purpose |
|---|---|
AffiliateSdk.configure({ apiKey, baseUrl, storage }) | Initialize once at startup |
AffiliateSdk.attribute(url) | Record attribution from an incoming link |
AffiliateSdk.applyCode(code) | Manual-code attribution fallback |
AffiliateSdk.identify(userId) | Bind your user id to the attribution |
AffiliateSdk.attributedAffiliateId() | The attributed affiliate id (or null) |
All calls resolve to false/null on network failure — never a thrown error in your
render path.