React Native

Add Fload's attribution package to a bare React Native app. One package covers iOS and Android. It's a native module over Fload's native SDKs, so it behaves exactly like them.

Using Expo? See the Expo guide.


What you need

  • React Native 0.74 or later. It's tested on 0.81 and 0.88.
  • iOS 15.1 or later, and Android minSdk 24 or later.
  • Your app's write key.
  • react-native-purchases in your app, if you want revenue per keyword. The package doesn't depend on it.

1. Install the package

bash
npm install @fload-ai/attribution-react-native
# or: yarn add @fload-ai/attribution-react-native
cd ios && pod install

Then rebuild the app. Autolinking adds the native code on both platforms, with the New Architecture or the old one.

On Android, the native SDK comes from JitPack. React Native's Gradle plugin adds JitPack to every project by default, so there's nothing to do. If your app sets includeJitpackRepository=false, add maven("https://jitpack.io") to your repositories.

Use this package or the native iOS SDK in an app, not both. The package already contains the iOS SDK, so don't also add the Swift package or pod.


2. Start it at app start

Call FloadAttribution.configure once, as your app starts. The top of your root component is a good place. It returns at once; the work runs in the background on the native side.

tsx
import { useEffect } from 'react';
import { Platform } from 'react-native';
import { FloadAttribution } from '@fload-ai/attribution-react-native';
import Purchases from 'react-native-purchases';

export default function App() {
  useEffect(() => {
    Purchases.configure({
      apiKey: Platform.OS === 'ios' ? 'appl_…' : 'goog_…',
    });

    FloadAttribution.configure('fload_pk_…');
    Purchases.getAppUserID().then((id) => FloadAttribution.setUserId(id));
  }, []);

  return <RootNavigator />;
}

When a user logs in, RevenueCat's id changes. Send the new one too:

ts
await Purchases.logIn('user_123');
FloadAttribution.setUserId(await Purchases.getAppUserID());

Fload keeps every id an install has had, so purchases before and after login both count.


4. Check it works

Turn on debug logs while you test:

ts
FloadAttribution.configure('fload_pk_…', { logLevel: 'debug' });

Run on a real iPhone and a real Android phone. The package logs through the native SDKs: the unified log subsystem com.fload.attribution on iOS, and the Logcat tag FloadAttribution on Android. Remove the debug option before you ship.

  • The iOS Simulator has no AdServices token.
  • Android builds you run from your machine have no Play referrer.

Both still send an install, without attribution. That's expected.


5. Ship it

Ship the update to both stores. A JavaScript-only update through a code push service doesn't add native code, so it can't add the SDK. Fill in the App Store privacy answers and the Play Data safety form from Privacy.


Troubleshooting

The iOS build fails in the fmt pod (React Native 0.81 on the old architecture, with Xcode 26). Build that pod as C++17. In ios/Podfile, add this inside your post_install block, after react_native_post_install(...), then run pod install again:

ruby
installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' if target.name == 'fmt'
  end
end

Setting FMT_USE_CONSTEVAL=0 doesn't fix it. React Native 0.88 and Expo SDK 58 build on Xcode 26 without this.


Reference

CallWhat it does
FloadAttribution.configure(key, options?)Starts the SDK. Call once, at app start. options.logLevel is 'none', 'error', 'warning' (the default), 'info' or 'debug'. An unknown level throws a TypeError
FloadAttribution.setUserId(userId)Links your user id to this install
FloadAttribution.getInstallReference()Resolves to this install's random reference, for support questions. null until the SDK has loaded, just after configure

FloadAttribution is also the package's default export.