{"id":15193,"library":"react-native-appsflyer","title":"AppsFlyer React Native SDK","description":"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.","status":"active","version":"6.17.9","language":"javascript","source_language":"en","source_url":"https://github.com/AppsFlyerSDK/react-native-appsflyer","tags":["javascript","react-native","react","native","appsflyer","typescript"],"install":[{"cmd":"npm install react-native-appsflyer","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-appsflyer","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-appsflyer","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for any React Native plugin, minimum version 0.62.0 is supported.","package":"react-native","optional":false}],"imports":[{"note":"The primary instance for interacting with the AppsFlyer SDK.","wrong":"const appsFlyer = require('react-native-appsflyer');","symbol":"appsFlyer","correct":"import appsFlyer from 'react-native-appsflyer';"},{"note":"Used for sending user consent for DMA compliance. Note that `forGDPRUser` and `forNonGDPRUser` constructors were deprecated in v6.16.2.","wrong":"import AppsFlyerConsent from 'react-native-appsflyer/AppsFlyerConsent';","symbol":"AppsFlyerConsent","correct":"import { AppsFlyerConsent } from 'react-native-appsflyer';"},{"note":"This is a TypeScript type definition for handling deep link responses. Use `import type` for type-only imports to prevent bundling issues.","wrong":"import { DeepLinkResult } from 'react-native-appsflyer';","symbol":"DeepLinkResult","correct":"import type { DeepLinkResult } from 'react-native-appsflyer';"}],"quickstart":{"code":"import appsFlyer from 'react-native-appsflyer';\nimport { Platform } from 'react-native';\nimport type { DeepLinkResult } from 'react-native-appsflyer';\n\nconst appsFlyerDevKey = process.env.APPSFLYER_DEV_KEY ?? 'YOUR_APPSFLYER_DEV_KEY';\n// iOS App ID is required for iOS initialization\nconst appleAppID = Platform.OS === 'ios' ? (process.env.APPLE_APP_ID ?? 'YOUR_APPLE_APP_ID') : '';\n\nappsFlyer.initSdk(\n  {\n    devKey: appsFlyerDevKey,\n    isDebug: true,\n    appId: appleAppID, // Only for iOS. Ensure this is a string.\n    // Add conversion data and deep link listeners here if needed\n    // onInstallConversionDataListener: (data) => console.log('Install Conversion Data:', data),\n    // onDeepLinkListener: (result) => console.log('Deep Link Listener Data:', result),\n  },\n  (success) => {\n    console.log('AppsFlyer SDK initialized successfully:', success);\n    // Log a custom in-app event, e.g., a purchase\n    appsFlyer.logEvent(\n      'af_purchase',\n      {\n        af_content_id: 'product_id_123',\n        af_content_type: 'product',\n        af_currency: 'USD',\n        af_price: 29.99,\n        af_revenue: 29.99,\n      },\n      (eventSuccess) => console.log('Purchase event logged:', eventSuccess),\n      (eventError) => console.error('Error logging purchase event:', eventError)\n    );\n  },\n  (error) => {\n    console.error('AppsFlyer SDK initialization failed:', error);\n  }\n);\n\n// Example of setting up a global deep link listener\nappsFlyer.onDeepLink(\n  (res: DeepLinkResult) => {\n    console.log('Unified Deep Link received:', res);\n    // Implement deep link routing logic here\n    if (res.status === 'FOUND' && res.deepLink) {\n      console.log('Deep link data:', res.deepLink);\n    }\n  }\n);\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"Starting 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.","severity":"breaking","affected_versions":">=6.17.1"},{"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.","message":"Starting with version 6.16.2, `AppsFlyerConsent.forGDPRUser` and `AppsFlyerConsent.forNonGDPRUser` constructors have been deprecated. Using these will result in warnings or runtime errors.","severity":"deprecated","affected_versions":">=6.16.2"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=6.15.1"},{"fix":"Update your iOS project's minimum deployment target to 12.0 or higher in Xcode (Project -> Target -> General -> Minimum Deployments).","message":"As 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.","severity":"breaking","affected_versions":">=6.15.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Replace `AppsFlyerConsent.forGDPRUser` or `AppsFlyerConsent.forNonGDPRUser` with the new `AppsFlyerConsent` constructor as per the latest documentation for DMA compliance.","cause":"Attempting to use deprecated consent management methods after version 6.16.2.","error":"TypeError: AppsFlyerConsent.forGDPRUser is not a function"},{"fix":"Update your TypeScript code to use the `additionalParameters` object directly on the `PurchaseRevenueDataSource` or `PurchaseRevenueDataSourceStoreKit2` interfaces.","cause":"Using the old TypeScript interfaces for Purchase Connector data sources after the breaking change in version 6.17.1.","error":"Type error: Property 'purchaseRevenueAdditionalParametersForProducts' does not exist on type 'PurchaseRevenueDataSource'"},{"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.","cause":"Common error during Android build due to network issues, repository access, or incorrect Gradle setup.","error":"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"},{"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.","cause":"Incorrect Java Development Kit (JDK) configuration, often after upgrading the Android SDK version which now requires Java 17.","error":"ERROR: JAVA_HOME is set to an invalid directory. It must be set to a JDK, not a JRE."}],"ecosystem":"npm"}