Appfiliate Docs
appfiliate.io

React Native SDK

Add affiliate install and purchase attribution to your React Native app with a single npm package.


Prerequisites

  • React Native 0.70 or later
  • An Appfiliate account with an App ID and API Key (available at app.appfiliate.io)

Step 1: Install the package

Install the Appfiliate React Native package from npm:

Terminal
npm install appfiliate-react-native

If you use Yarn:

Terminal
yarn add appfiliate-react-native

iOS: run pod install

After installing the package, run cd ios && pod install to link the native iOS dependency.

Step 2: Configure and track install

Initialize the SDK in your app's root component or entry point. Replace the placeholder values with the App ID and API Key from your Appfiliate dashboard.

App.tsx (functional component)

App.tsx
import React, { useEffect } from 'react';
import { appfiliate } from 'appfiliate-react-native';

function App() {
  useEffect(() => {
    async function initAppfiliate() {
      appfiliate.configure({ appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY' });
      await appfiliate.trackInstall();
    }

    initAppfiliate();
  }, []);

  return (
    // Your app content
  );
}

export default App;

index.js (entry point)

index.js
import { AppRegistry } from 'react-native';
import { appfiliate } from 'appfiliate-react-native';
import App from './App';
import { name as appName } from './app.json';

appfiliate.configure({ appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY' });
appfiliate.trackInstall();

AppRegistry.registerComponent(appName, () => App);

Step 3: Track purchases (optional)

To attribute revenue to affiliates, call trackPurchase() after every successful in-app purchase.

PurchaseHandler.tsx
import { appfiliate } from 'appfiliate-react-native';

async function handlePurchase(purchase: Purchase) {
  // After verifying the purchase was successful:
  await appfiliate.trackPurchase({
    productId: purchase.productId,
    revenue: 9.99,
    currency: 'USD',
    transactionId: purchase.transactionId,
  });
}

Works with any IAP library

The Appfiliate SDK is compatible with popular in-app purchase libraries like react-native-iap and expo-in-app-purchases. Just call trackPurchase() after a successful transaction from any library.

Important notes

No special permissions required

The Appfiliate SDK does not use IDFA on iOS or advertising IDs on Android. No ATT prompt is needed. Attribution is handled through deterministic matching.
  • trackInstall() is safe to call on every app launch. It only fires once per install.
  • trackPurchase() should be called after every successful in-app purchase.
  • The SDK is under 200 KB with zero external dependencies.
  • Works alongside any other analytics or attribution provider.