React Native Plugin

  • Advertisers
  • Developers


You can also find the plugin on npm here:

Set out below are the integration instructions for using AppsFlyer’s React Plugin.

This is the React Native plugin for AppsFlyer SDK.

This plugin is built for

  • iOS AppsFlyerSDK v4.7.3
  • Android AppsFlyerSDK v4.7.1

Installation Instructions

Follow these steps for the installation instructions for the AppsFlyer plugin:

First, download the library from npm: 

$ npm install react-native-appsflyer --save


iOS Android
1.  Add the appsFlyerFramework to podfile and run pod install.


target 'demo' do
  pod 'AppsFlyerFramework'

If you do not use CocoaPods, refer to their documentation here.

2.  Create bridge between your application and appsFlyerFramework

3.  In XCode >> project navigator, right click Libraries >> Add Files to [your project's name]

4.  Go to node_modules >> react-native-appsflyer and add RNAppsFlyer.xcodeproj

5.  Build your project

6.  The libRNAppsFlyer.a file is generated

7.  Run your project (Cmd+R) or through CLI run: react-native run-ios

API Methods

Call module by adding:

import appsFlyer from 'react-native-appsflyer';
appsFlyer.initSdk(options, onSuccess, onError): void

Initialize the SDK

Parameter Type Description
options  Object   SDK configuration
onSuccess Function returns callback object
onError Function returns callback object


Name Type Default Description
 devKey  string    Appsflyer Dev key
 appId  string    Apple Application ID (for iOS only)  
 isDebug   boolean  false  debug mode (optional)


let options = {
    devKey: 'WdpTVAcYwmxsaQ4WeTspmh', 
    appId: "975313579", 
    isDebug: true 
appsFlyer.initSdk(options, (error, result) => { 
    if (error) 
    { console.error(error); 
    } else { 
appsFlyer.trackEvent(eventName, eventValues, callback): void
  • These in-app events help you track how loyal users discover your app, and attribute them to specific campaigns/media-sources. Please take the time define the events you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
  • The trackEvent method allows you to send in-app events to AppsFlyer analytics. This method allows you to add events dynamically by adding them directly to the application code.
Parameter Type Description
eventName  String  Custom event name, is presented in your dashboard. See the Event List here 
eventValue  Object  event details


 const eventName = "af_add_to_cart";
 const eventValues = {
      "af_content_id": "id123",
      "af_revenue": "2"

 appsFlyer.trackEvent(eventName, eventValues, (error, result) => {
     if (error) {
     } else {

Measure App Uninstalls

iOS Android
AppsFlyer enables you to measure app uninstalls. To handle notifications it requires to modify your AppDelegate.m. Use didRegisterForRemoteNotificationsWithDeviceToken to register to the uninstall feature.


- (void)application:(UIApplication ​*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *​)deviceToken {
   // notify AppsFlyerTracker
   [[AppsFlyerTracker sharedTracker] registerUninstall:deviceToken];

Read more about Uninstall register: AppsFlyer SDK support site


    const  gcmProjectId = "987186475229";
        (gcmProjectID) => {
        (error) => {

Read more about Android Uninstall Measurement: AppsFlyer SDK support site

appsFlyer.onInstallConversionData(callback): function:unregister

Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deep Linking). Read more: Android, iOS

Parameter Type Description
 callback  function  returns object 

Callback Structure

  • status: "success"or "failure" if SDK returned error on onInstallConversionData event handler
  • type:
    • "onAppOpenAttribution" - returns deep linking data (non-organic)
    • "onInstallConversionDataLoaded" - called on each launch
    • "onAttributionFailure"
    • "onInstallConversionFailure"
  • data: some metadata, for example:

<preclass="language-json">{ "status": "success", "type": "onInstallConversionDataLoaded", "data": { "af_status": "Organic", "af_message": "organic install" } }


this.onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(
	(data) => {

The appsFlyer.onInstallConversionData returns function to unregister this event listener. Actually it calls NativeAppEventEmitter.remove()


componentWillUnmount() {

appsFlyer.getAppsFlyerUID(callback): void

Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.


appsFlyer.getAppsFlyerUID((error, appsFlyerUID) => {
	if (error) {
	} else {
	console.log("on getAppsFlyerUID: " + appsFlyerUID);

appsFlyer.trackLocation(longitude, latitude, callback(error, coords): void (iOS only)

Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.

Parameter Type Description
 error   String  Error callback - called on getAppsFlyerUID failure 
 appsFlyerUID   string  The AppsFlyer Device ID


const  latitude = -18.406655;
const  longitude = 46.406250;

appsFlyer.trackLocation(longitude, latitude, (error, coords) => {
	if (error) {
	} else {
		this.setState( { ...this.state, trackLocation: coords });


This plugin has a demo project bundled with it. To give it a try , clone this repo and from root a.e. react-native-appsflyerexecute the following:

npm run setup
  • Run npm run demo.ios or npm run demo.ios will run for the appropriate platform.
  • Run npm run ios-pod to run Podfile under demo project
Was this article helpful?
1 out of 1 found this helpful