Registry / communication / react-native-appsflyer

react-native-appsflyer

JSON →
library6.17.9jsnpmunverified

react-native-appsflyer is the official React Native plugin for integrating the AppsFlyer mobile attribution and marketing analytics SDK. It provides comprehensive functionalities for tracking installs, in-app events, deep linking, and consent management across iOS and Android platforms. The current stable version is 6.17.9, with frequent patch releases, indicating active development and maintenance. Key differentiators include robust support for purchase validation via the Purchase Connector (since 6.17.1), unified deep linking (UDL), and explicit handling of consent for DMA compliance. The plugin is built for Android AppsFlyer SDK v6.17.6 and iOS AppsFlyer SDK v6.17.9, and is tested with React Native v0.62.0 and above, ensuring compatibility with modern React Native projects. It ships with TypeScript types, facilitating type-safe development.

npm install react-native-appsflyer
INSTALL
IMPORT
SIG · REACT-NATIVE-APPSF
R
react-native-appsflyer
communicationjavascriptv6.17.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

appsFlyer
import appsFlyer from 'react-native-appsflyer';
const appsFlyer = require('react-native-appsflyer');
The primary instance for interacting with the AppsFlyer SDK.
AppsFlyerConsent
import { AppsFlyerConsent } from 'react-native-appsflyer';
import AppsFlyerConsent from 'react-native-appsflyer/AppsFlyerConsent';
Used for sending user consent for DMA compliance. Note that `forGDPRUser` and `forNonGDPRUser` constructors were deprecated in v6.16.2.
DeepLinkResult
import type { DeepLinkResult } from 'react-native-appsflyer';
import { DeepLinkResult } from 'react-native-appsflyer';
This is a TypeScript type definition for handling deep link responses. Use `import type` for type-only imports to prevent bundling issues.

This quickstart demonstrates how to initialize the AppsFlyer SDK for both iOS and Android, log a custom in-app event (purchase), and set up a listener for Unified Deep Links. Remember to replace placeholder keys.

import appsFlyer from 'react-native-appsflyer'; import { Platform } from 'react-native'; import type { DeepLinkResult } from 'react-native-appsflyer'; const appsFlyerDevKey = process.env.APPSFLYER_DEV_KEY ?? 'YOUR_APPSFLYER_DEV_KEY'; // iOS App ID is required for iOS initialization const appleAppID = Platform.OS === 'ios' ? (process.env.APPLE_APP_ID ?? 'YOUR_APPLE_APP_ID') : ''; appsFlyer.initSdk( { devKey: appsFlyerDevKey, isDebug: true, appId: appleAppID, // Only for iOS. Ensure this is a string. // Add conversion data and deep link listeners here if needed // onInstallConversionDataListener: (data) => console.log('Install Conversion Data:', data), // onDeepLinkListener: (result) => console.log('Deep Link Listener Data:', result), }, (success) => { console.log('AppsFlyer SDK initialized successfully:', success); // Log a custom in-app event, e.g., a purchase appsFlyer.logEvent( 'af_purchase', { af_content_id: 'product_id_123', af_content_type: 'product', af_currency: 'USD', af_price: 29.99, af_revenue: 29.99, }, (eventSuccess) => console.log('Purchase event logged:', eventSuccess), (eventError) => console.error('Error logging purchase event:', eventError) ); }, (error) => { console.error('AppsFlyer SDK initialization failed:', error); } ); // Example of setting up a global deep link listener appsFlyer.onDeepLink( (res: DeepLinkResult) => { console.log('Unified Deep Link received:', res); // Implement deep link routing logic here if (res.status === 'FOUND' && res.deepLink) { console.log('Deep link data:', res.deepLink); } } );
Debug
Known issues
breakingStarting with version 6.17.1, the TypeScript interfaces for Purchase Connector data sources (`PurchaseRevenueDataSource` and `PurchaseRevenueDataSourceStoreKit2`) have undergone breaking changes. Specifically, `purchaseRevenueAdditionalParametersForProducts()` and `purchaseRevenueAdditionalParametersStoreKit2ForProducts()` functions have been replaced with a simpler `additionalParameters` object.
fix
Update your TypeScript code consuming Purchase Connector data sources to use the new `additionalParameters` object instead of the deprecated functions. Refer to the official documentation for updated interface definitions.
affects: >=6.17.1
deprecatedStarting with version 6.16.2, `AppsFlyerConsent.forGDPRUser` and `AppsFlyerConsent.forNonGDPRUser` constructors have been deprecated. Using these will result in warnings or runtime errors.
fix
Migrate to the new `AppsFlyerConsent` constructor to manage user consent for data privacy regulations. Consult the 'Send consent for DMA compliance' documentation for the updated API.
affects: >=6.16.2
breakingVersion 6.15.1 introduced significant changes for Android builds, upgrading to targetSDKVersion 34, Java 17, and Gradle 8.7. This requires your React Native project's Android setup to match these versions or be compatible, potentially causing build failures if not addressed.
fix
Ensure your project's `build.gradle` and environment are updated to support `targetSDKVersion 34`, Java 17, and Gradle 8.7. Check your `android/build.gradle` and `android/app/build.gradle` files for necessary adjustments.
affects: >=6.15.1
breakingAs of version 6.15.1, the iOS minimum deployment target has been increased to 12.0. Projects targeting older iOS versions will fail to build.
fix
Update your iOS project's minimum deployment target to 12.0 or higher in Xcode (Project -> Target -> General -> Minimum Deployments).
affects: >=6.15.1
Errors
Common errors & fixes
TypeError: AppsFlyerConsent.forGDPRUser is not a function
Attempting to use deprecated consent management methods after version 6.16.2.
fix
Replace `AppsFlyerConsent.forGDPRUser` or `AppsFlyerConsent.forNonGDPRUser` with the new `AppsFlyerConsent` constructor as per the latest documentation for DMA compliance.
Type error: Property 'purchaseRevenueAdditionalParametersForProducts' does not exist on type 'PurchaseRevenueDataSource'
Using the old TypeScript interfaces for Purchase Connector data sources after the breaking change in version 6.17.1.
fix
Update your TypeScript code to use the `additionalParameters` object directly on the `PurchaseRevenueDataSource` or `PurchaseRevenueDataSourceStoreKit2` interfaces.
Could not GET 'https://repo.maven.apache.org/maven2/com/appsflyer/af-android-sdk/6.15.1/af-android-sdk-6.15.1.pom'. Received status code 403 from server: Forbidden
Common error during Android build due to network issues, repository access, or incorrect Gradle setup.
fix
Verify your internet connection. Ensure your `android/build.gradle` file's `allprojects` block includes `mavenCentral()` or `google()` repositories. Sometimes, clearing Gradle cache (`./gradlew clean` and deleting `.gradle` folder in `android/` directory) helps.
ERROR: JAVA_HOME is set to an invalid directory. It must be set to a JDK, not a JRE.
Incorrect Java Development Kit (JDK) configuration, often after upgrading the Android SDK version which now requires Java 17.
fix
Ensure `JAVA_HOME` environment variable points to a valid JDK installation (e.g., OpenJDK 17) and not just a JRE. Reinstalling or updating your JDK and adjusting environment variables is usually required.
Upgrade
Version history
6.17.9latest on npm
Audit
Dependencies
react-nativerequiredCore dependency for any React Native plugin, minimum version 0.62.0 is supported.
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources