| title | API reference |
|---|---|
| category | 5f9705393c689a065c409b23 |
| parentDoc | 645213236f53a00d4daa9230 |
| order | 11 |
| hidden | false |
The list of available methods for this plugin is described below.
Upgrading from 6.x? This page documents the current (7.0.0+) API only. For every renamed/removed/changed method — with a full before/after table — see MIGRATION.md.
- APIs
- Android and iOS APIs
- Initialization Flow
- init
- start
- enableDebug
- logEvent
- setCustomerUserId
- stop
- setAppInviteOneLink
- setAdditionalData
- setResolveDeepLinkURLs
- setOneLinkCustomDomain
- setCurrencyCode
- logLocation
- anonymizeUser
- getAppsFlyerUID
- getSdkVersion
- setHost
- setUserEmail
- setUserEmails — removed in 7.0.0
- setUserPhone
- setUserFirstName
- setUserLastName
- setUserFbLoginId
- clearUserPii
- generateInviteLink
- logInvite
- logCrossPromoteImpression
- logAndOpenStore
- setSharingFilterForAllPartners / setSharingFilter — removed in 7.0.0
- setSharingFilterForPartners
- setPartnerData
- validateAndLogInAppPurchase
- updateServerUninstallToken
- sendPushNotificationData
- handlePushNotification
- addPushNotificationDeepLinkPath
- appendParametersToDeepLinkingURL
- setDisableAdvertisingIdentifiers
- enableTCFDataCollection
- setConsentData
- logAdRevenue
- setMinTimeBetweenSessions
- setInstallId
- setDeepLinkTimeout
- enableFacebookDeferredApplinks
- Android Only APIs
- setCollectAndroidID
- setCollectIMEI — removed in 7.0.0
- setDisableNetworkData
setDisableNetworkData(isDisable) - performDeepLinking
- disableAppSetId
- getHostName
- getHostPrefix
- getOutOfStore
- setOutOfStore
- getAttributionId
- isStopped
- isPreInstalledApp
- setLogLevel
- setIsUpdate
- setAppId
- setPreinstallAttribution
- logSession
- onPause
- collectDataFromLauncherActivity
- iOS Only APIs
- AppsFlyerConversionData
Recommended call order for a 7.0.0 (RPC) integration:
registerDeepLinkListener— call this beforeinit(), on both platforms. See "Why the order matters" below.init({devKey, appId})enableDebug({enabled: true})— not order-critical relative toinit; call it as early as possible (even beforeinit) to get full debug logs from the start of the sessionregisterConversionListener— synchronously, in the same call stack asinit, not insideinit()'s.then()setCustomerUserId(...)— if you need the CUID associated with the install eventregisterSessionReadyListener(...)— synchronously, same rule as step 4- Inside the
registerSessionReadyListenercallback: collect consent data (setConsentData) / ATT authorization status if your app requires it, then callstart()
registerDeepLinkListener is the one listener that goes before init() instead of after — every other listener follows the simple "synchronously, right after init()" rule.
Example:
import AppsFlyer from 'react-native-appsflyer';
const onDeepLink = (res) => {
// ...
};
AppsFlyer.registerDeepLinkListener({ onDeepLinking: onDeepLink });
AppsFlyer.init({ devKey: 'K2***********99', appId: '41*****44' }).then(
(res) => console.log('init', res),
(err) => console.error('init failed', err)
);
AppsFlyer.enableDebug({ enabled: true });
AppsFlyer.registerConversionListener({
onConversionDataSuccess: (res) => {
// ...
},
onConversionDataFail: (error) => {
// ...
},
});
// AppsFlyer.setCustomerUserId({ customerId: 'some_user_id' }); // if needed, before start
AppsFlyer.registerSessionReadyListener(() => {
// Collect consent / ATT status here if your app requires it, e.g.:
// AppsFlyer.setConsentData(consent);
AppsFlyer.start().then(
() => console.log('SDK started'),
(err) => console.error('start failed', err)
);
});Why the order matters:
initmust be issued first, except forregisterDeepLinkListener— see below.enableDebugand the listener registrations all go over the same native RPC channel in call order — issuing them right afterinitguarantees the native side processesinitfirst, even thoughinit()'s own JS Promise resolves later, asynchronously.registerConversionListenerandregisterSessionReadyListenermust be registered beforeinit()'s promise settles. Registration itself is init-order-independent for these two, but dispatch still happens in call order — registering insideinit().then()delays dispatch and risks missing an event that fires shortly after init.registerDeepLinkListenergoes beforeinit()on both platforms: Android's native SDK does not buffer a deep-link result delivered before a listener is attached — any result that arrives first is dropped, permanently, with no retry — so registering first closes that window. iOS used to have the opposite constraint (a one-shot deferred-deep-link trigger that fired immediately on attach and permanently burned itself against an unconfigured host if called too early), but that was fixed upstream in the native SDK; both platforms are now safe to register beforeinit(), so there's no more platform split for this call.start()must be called from inside theregisterSessionReadyListenercallback, never chained offinit().then()— see start.- These calls are ordered by dispatch, not by completion: it's the call order on the native RPC channel that matters, not whether
init()'s promise has resolved yet.
initSdk(options, success, error) is removed. Use init(params) instead — a Promise-only call. isDebug, onInstallConversionDataListener, onDeepLinkListener, and manualStart are no longer options on the init call; see
MIGRATION.md for the full
replacement pattern (enableDebug, registerConversionListener, registerDeepLinkListener,
registerSessionReadyListener + start), and Initialization Flow above for the recommended call order.
| parameter | type | description |
|---|---|---|
| devKey | string | your AppsFlyer dev key |
| appId | string | null | Apple App ID (numeric). Required on iOS, unused on Android — pass it unconditionally. Optional |
Example:
import AppsFlyer from 'react-native-appsflyer';
AppsFlyer.init({ devKey: 'K2***********99', appId: '41*****44' }).then(
(res) => console.log(res),
(err) => console.error(err)
);
AppsFlyer.registerSessionReadyListener(() => {
AppsFlyer.start();
});start(params?) : Promise<void>
7.0.0 always requires an explicit start() call — the native SDK never auto-starts (there is
no manualStart option any more, since initSdk itself is removed; see
MIGRATION.md). Call start() from inside
registerSessionReadyListener's callback, after any consent/ATT status you need to collect — see Initialization Flow for call ordering and why the order matters.
| parameter | type | description |
|---|---|---|
| awaitResponse | boolean | optional; wait for the native SDK's own completion handler instead of resolving immediately |
params itself is optional — start() can be called with zero arguments.
Example:
AppsFlyer.init({ devKey: 'UsxXxXxed', appId: '75xXxXxXxXx11' });
AppsFlyer.registerSessionReadyListener(() => {
AppsFlyer.start().then(
() => console.warn('AppsFlyer SDK started!'),
(err) => { /* handle error */ }
);
});enableDebug(params) : Promise<void>
Enable native SDK debug logging. Dispatched as its own RPC call, separate from init. Not
order-critical relative to init — call it as early as possible (even before init) to get
full debug logs from the start of the session.
| parameter | type | description |
|---|---|---|
| enabled | boolean | true to enable debug logs |
Example:
AppsFlyer.enableDebug({ enabled: true });logEvent(params) : Promise<void>
Records an in-app event — see In-App Events for concepts and event naming rules (45-character limit).
| parameter | type | description |
|---|---|---|
| eventName | string | The name of the event |
| eventValues | json | optional; the event values that are sent with the event |
| awaitResponse | boolean | optional; see below |
Example:
const eventName = 'af_add_to_cart';
const eventValues = {
af_content_id: 'id123',
af_currency: 'USD',
af_revenue: '2',
};
AppsFlyer.logEvent({ eventName, eventValues }).then(
(res) => console.log(res),
(err) => console.error(err)
);awaitResponse: by default resolves once the SDK accepts the event onto its internal queue — not once it's delivered to AppsFlyer's server. Pass awaitResponse: true to instead wait for the native SDK's own completion handler (round-trips to AppsFlyer's server).
Every plugin API call returns a Promise, so where you genuinely need one call to complete before the next, use async/await normally — e.g. await AppsFlyer.init(params) before your first logEvent call:
await AppsFlyer.init({ devKey, appId });
await AppsFlyer.logEvent({ eventName, eventValues });A frozen object of predefined in-app event name constants (e.g. af_purchase, af_login, af_add_to_cart) for use as eventName.
import AppsFlyer, { AFInAppEventType } from 'react-native-appsflyer';
AppsFlyer.logEvent({ eventName: AFInAppEventType.PURCHASE, eventValues: { af_revenue: 2 } });setCustomerUserId(params) : Promise<void>
Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID is available in AppsFlyer CSV reports along with postbacks APIs for cross-referencing with you internal IDs.
If you wish to see the CUID (Customer User ID) under your installs raw data reports, it should be called before starting the SDK.
If you simply would like to add additional user id to the events raw data reports, then you can freely call it anytime you need.
| parameter | type | description |
|---|---|---|
| customerId | string | user ID |
Example:
AppsFlyer.setCustomerUserId({ customerId: 'some_user_id' });stop(params) : Promise<void>
In some extreme cases you might want to shut down all SDK functions due to legal and privacy compliance. This can be achieved with the stopSDK API. Once this API is invoked, our SDK no longer communicates with our servers and stops functioning.
There are several different scenarios for user opt-out. We highly recommend following the exact instructions for the scenario, that is relevant for your app.
In any event, the SDK can be reactivated by calling the same API, by passing false.
| parameter | type | description |
|---|---|---|
| shouldStop | boolean | True if the SDK is stopped (default value is false). |
Example:
AppsFlyer.stop({ shouldStop: true });setAppInviteOneLink(params) : Promise<void>
Sets the OneLink ID used as the base link ID for User Invite — see User Invite for call-order requirements and full usage.
| parameter | type | description |
|---|---|---|
| oneLinkId | string | oneLinkId |
Example:
AppsFlyer.setAppInviteOneLink({ oneLinkId: 'abcd' });setAdditionalData(params) : Promise<void>
The setAdditionalData API is required to integrate on the SDK level with several external partner platforms, including Segment, Adobe and Urban Airship. Use this API only if the integration article of the platform specifically states setAdditionalData API is needed.
| parameter | type | description |
|---|---|---|
| customData | json | additional data |
Example:
AppsFlyer.setAdditionalData({
customData: {
val1: 'data1',
val2: false,
val3: 23,
},
});setResolveDeepLinkURLs(params) : Promise<void>
Set domains used by ESP when wrapping your deeplinks.
Use this API during the SDK Initialization to indicate that links from certain domains should be resolved in order to get original deeplink
For more information please refer to the documentation
| parameter | type | description |
|---|---|---|
| urls | string[] | array of ESP domains requiring resolving |
Example:
AppsFlyer.setResolveDeepLinkURLs({ urls: ['click.esp-domain.com'] }).then(
(res) => console.log(res),
(error) => console.log(error)
);setOneLinkCustomDomain(params) : Promise<void>
Set Onelink custom/branded domains
Use this API during the SDK Initialization to indicate branded domains.
For more information please refer to the documentation
| parameter | type | description |
|---|---|---|
| domains | string[] | array of branded domains |
Example:
AppsFlyer.setOneLinkCustomDomain({ domains: ['click.mybrand.com'] }).then(
(res) => {
console.log(res);
}, (error) => {
console.log(error);
});setCurrencyCode(params) : Promise<void>
Setting user local currency code for in-app purchases.
The currency code should be a 3 character ISO 4217 code. (default is USD).
You can set the currency code for all events by calling the following method.
| parameter | type | description |
|---|---|---|
| currencyCode | string | currencyCode |
Example:
AppsFlyer.setCurrencyCode({ currencyCode: 'USD' });logLocation(params) : Promise<void>
Manually record the location of the user.
| parameter | type | description |
|---|---|---|
| longitude | number | longitude |
| latitude | number | latitude |
Example:
const latitude = -18.406655;
const longitude = 46.40625;
AppsFlyer.logLocation({ longitude, latitude });anonymizeUser(params) : Promise<void>
It is possible to anonymize specific user identifiers within AppsFlyer analytics. This complies with both the latest privacy requirements (GDPR, COPPA) and Facebook's data and privacy policies. To anonymize an app user.
| parameter | type | description |
|---|---|---|
| shouldAnonymize | boolean | True if want Anonymize user Data (default value is false). |
Example:
AppsFlyer.anonymizeUser({ shouldAnonymize: true });getAppsFlyerUID() : Promise<string>
AppsFlyer's unique device ID is created for every new install of an app. Use the following API to obtain AppsFlyer’s Unique ID.
Example:
try {
const appsFlyerUID = await AppsFlyer.getAppsFlyerUID();
console.log('on getAppsFlyerUID: ' + appsFlyerUID);
} catch (err) {
console.error(err);
}getSdkVersion() : Promise<string>
Returns the AppsFlyer native SDK version used by the plugin.
Example:
const version = await AppsFlyer.getSdkVersion();
console.log('AppsFlyer SDK version: ' + version);setHost(params) : Promise<void>
Set a custom host
| parameter | type | description |
|---|---|---|
| hostPrefixName | string | the host prefix |
| hostName | string | the host name |
Example:
AppsFlyer.setHost({ hostPrefixName: 'foo', hostName: 'bar.appsflyer.com' });setUserEmail(params) : Promise<void>
Set the user email. The email is hashed by the native SDK before transmission.
| parameter | type | description |
|---|---|---|
| string | the user's email address |
Example:
AppsFlyer.setUserEmail({ email: 'user1@gmail.com' }).then(
(res) => console.log(res),
(err) => console.error(err)
);setUserEmails(options, success, error) is removed with no adapter (it was already
@deprecated pre-release, so it never shipped as a callable 7.0.0 API). Use
setUserEmail instead — a single-address, Promise-only call. See
MIGRATION.md.
setUserPhone(params) : Promise<void>
Set the user phone number. The number is hashed by the native SDK before transmission.
The native SDK reads a split country code and subscriber number — a single combined string is not supported.
| parameter | type | description |
|---|---|---|
| countryCode | string | country code, e.g. '1' or '+1' |
| phoneNumber | string | subscriber number, without the country code |
Example:
AppsFlyer.setUserPhone({ countryCode: '1', phoneNumber: '5551234567' });setUserFirstName(params) : Promise<void>
Set the user's first name. Hashed by the native SDK before transmission.
| parameter | type | description |
|---|---|---|
| firstName | string | the user's first name |
Example:
AppsFlyer.setUserFirstName({ firstName: 'Jane' });setUserLastName(params) : Promise<void>
Set the user's last name. Hashed by the native SDK before transmission.
| parameter | type | description |
|---|---|---|
| lastName | string | the user's last name |
Example:
AppsFlyer.setUserLastName({ lastName: 'Doe' });setUserFbLoginId(params) : Promise<void>
Set the user's Facebook login ID. Facebook login IDs run 15-18 digits, past JavaScript's 53-bit safe-integer range — a number that large has already lost precision by the time it reaches this call. Pass a numeric string instead; native parses it directly with full 64-bit precision.
| parameter | type | description |
|---|---|---|
| fbLoginId | string | number | numeric Facebook login ID — use a string for IDs at or near 2^53 |
Example:
AppsFlyer.setUserFbLoginId({ fbLoginId: '1234567890' }); // safe for any length
AppsFlyer.setUserFbLoginId({ fbLoginId: 1234567890 }); // fine only for short IDs well under 2^53clearUserPii() : Promise<void>
Clear all previously set hashed PII (phone, first/last name, Facebook login ID, emails). Takes no arguments.
Example:
AppsFlyer.clearUserPii();generateInviteLink(params?) : Promise<string>
| parameter | type | description |
|---|---|---|
| parameters | json | optional; parameters for Invite link |
| awaitResponse | boolean | optional |
Example:
AppsFlyer.generateInviteLink({
parameters: {
channel: 'gmail',
campaign: 'myCampaign',
customerID: '1234',
userParams: {
myParam: 'newUser',
anotherParam: 'fromWeb',
amount: 1,
},
},
}).then(
(link) => console.log(link),
(err) => console.log(err)
);A complete list of supported parameters is available here. Custom parameters can be passed using a userParams{} nested object, as in the example above.
Note:
customerIDandbaseDeeplinkare supported. The plugin translates them to the native key names for you (iOSreferrerCustomerId, AndroidcustomerId, bothbaseDeepLink).
logInvite(params) : Promise<void>
Log a user invite event.
| parameter | type | description |
|---|---|---|
| channel | string | the channel through which the invite was sent. |
| eventParameters | object | additional event parameters. Optional. |
Example:
AppsFlyer.logInvite({ channel: 'facebook', eventParameters: { af_content_id: 'id123' } });logCrossPromoteImpression(params) : Promise<void>
Attribute an impression for a cross-promotion. Use the promoted App ID as it appears within the AppsFlyer dashboard.
| parameter | type | description |
|---|---|---|
| appId | string | promoted App ID |
| campaign | string | cross promotion campaign. Optional. |
| userParams | object | additional params to be added to the attribution link. Optional. |
Example:
AppsFlyer.logCrossPromoteImpression({ appId: '123456789', campaign: 'myCampaign', userParams: { af_sub1: 'value' } });logAndOpenStore(params) : Promise<void>
Attribute a cross-promotion click and launch the app store's app page.
| parameter | type | description |
|---|---|---|
| promotedAppId | string | promoted App ID |
| campaign | string | cross promotion campaign. Optional. |
| userParams | object | additional user params. Optional. |
Example:
AppsFlyer.logAndOpenStore({ promotedAppId: '123456789', campaign: 'myCampaign', userParams: { af_sub1: 'value' } });Both were deprecated since 6.4.0 in favor of setSharingFilterForPartners and are now
removed with no adapter. See
MIGRATION.md.
Use setSharingFilterForPartners(['all']) or setSharingFilterForPartners([...partners])
instead (documented below).
setSharingFilterForPartners(params) : Promise<void>
Used by advertisers to exclude networks/integrated partners from getting data.
| parameter | type | description |
|---|---|---|
| partners | string[] | null | array of partners that need to be excluded |
Example:
AppsFlyer.setSharingFilterForPartners({ partners: [] }); // Reset list (default)
AppsFlyer.setSharingFilterForPartners({ partners: null }); // Reset list (default)
AppsFlyer.setSharingFilterForPartners({ partners: ['facebook_int'] }); // Single partner
AppsFlyer.setSharingFilterForPartners({ partners: ['facebook_int', 'googleadwords_int'] }); // Multiple partners
AppsFlyer.setSharingFilterForPartners({ partners: ['all'] }); // All partners
AppsFlyer.setSharingFilterForPartners({ partners: ['googleadwords_int', 'all'] }); // All partnerssetPartnerData(params) : Promise<void>
Allows sending custom data for partner integration purposes.
| parameter | type | description |
|---|---|---|
| partnerId | string | ID of the partner (usually suffixed with _int) |
| data | object | customer data, depends on the integration configuration with the specific partner |
Example:
AppsFlyer.setPartnerData({ partnerId: 'example_partner_int', data: { key: 'value' } });validateAndLogInAppPurchase(params) : Promise<Record<string, unknown>>
Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported.
Learn more - https://support.appsflyer.com/hc/en-us/articles/207032106-Receipt-validation-for-in-app-purchases
❗Important❗ for iOS - set SandBox to true
AppsFlyer.setUseReceiptValidationSandbox({ sandbox: true });
| parameter | type | description |
|---|---|---|
| purchase | object | AFPurchaseDetails — see below |
| additionalParameters | object | additional parameters. Optional. |
The purchase field uses AFPurchaseDetails (a union of AFPurchaseDetailsAndroid and AFPurchaseDetailsIOS) and AFPurchaseType enum for structured purchase validation. The two platforms report different native purchase identifiers — Android's purchaseToken vs. iOS's transactionId — so the shape is now split per platform instead of conflating both fields into one.
Note on the return value: A 401/500 logged via console.warn after calling this means the app isn't registered for purchase validation on the server side — this is expected, not a bridge failure. The pre-7.0.0 (purchaseInfo, successC, errorC) signature was removed with no adapter — see MIGRATION.md.
import { AFPurchaseType } from 'react-native-appsflyer';
AFPurchaseType.SUBSCRIPTION // "subscription"
AFPurchaseType.ONE_TIME_PURCHASE // "one_time_purchase"interface AFPurchaseDetailsAndroid {
productId: string; // Product identifier
purchaseToken: string; // Android purchase token
purchaseType: AFPurchaseType; // Type of purchase
}
interface AFPurchaseDetailsIOS {
productId: string; // Product identifier
transactionId: string; // iOS transaction identifier
purchaseType: AFPurchaseType; // Type of purchase
}
type AFPurchaseDetails = AFPurchaseDetailsAndroid | AFPurchaseDetailsIOS;import AppsFlyer, { AFPurchaseType } from 'react-native-appsflyer';
const additionalParams = {
revenue: 9.99,
currency: "USD"
};
// iOS
AppsFlyer.validateAndLogInAppPurchase({
purchase: {
productId: "deviceIdconsumableid",
transactionId: "2000000569065806",
purchaseType: AFPurchaseType.ONE_TIME_PURCHASE,
},
additionalParameters: additionalParams,
});
// Android
AppsFlyer.validateAndLogInAppPurchase({
purchase: {
productId: "deviceIdconsumableid",
purchaseToken: "purchase-token-from-billing-client",
purchaseType: AFPurchaseType.ONE_TIME_PURCHASE,
},
additionalParameters: additionalParams,
});updateServerUninstallToken(params) : Promise<void>
Manually pass the Firebase / GCM Device Token for Uninstall measurement.
| parameter | type | description |
|---|---|---|
| token | string | FCM Token |
Example:
AppsFlyer.updateServerUninstallToken({ token: 'token' });sendPushNotificationData(params) : Promise<void> — Android only
Push-notification campaigns are used to create fast re-engagements with existing users.
Learn more
AppsFlyer SDK uses the activity in order to process the push payload. Make sure you call this api when the app's activity is available (NOT dead state).
iOS uses the separate handlePushNotification call instead — no longer a single merged call.
| parameter | type | description |
|---|---|---|
| campaign | string | campaign name |
| pid | string | media source identifier |
| isRetargeting | boolean | true for a re-engagement. Optional. |
| additionalParameters | json | additional campaign parameters. Optional. |
Example:
if (Platform.OS === 'android') {
AppsFlyer.sendPushNotificationData({
campaign: 'test_campaign',
pid: 'push_provider_int',
isRetargeting: true,
});
}handlePushNotification(params) : Promise<void> — iOS only
Forwards a raw push-notification payload to the native SDK, which locates the af block itself. Android uses sendPushNotificationData instead — no longer a single merged call.
| parameter | type | description |
|---|---|---|
| pushPayload | json | the raw push notification payload |
Example:
const pushPayload = {
af: {
c: 'test_campaign',
is_retargeting: true,
pid: 'push_provider_int',
},
aps: {
alert: 'Get 5000 Coins',
badge: '37',
sound: 'default',
},
};
if (Platform.OS === 'ios') {
AppsFlyer.handlePushNotification({ pushPayload });
}addPushNotificationDeepLinkPath(params) : Promise<void>
Adds array of keys, which are used to compose key path to resolve deeplink from push notification payload.
| parameter | type | description |
|---|---|---|
| deepLinkPath | string[] | array of strings that corresponds to the JSON path of the deep link. |
Example:
const deepLinkPath = ['deeply', 'nested', 'deep_link'];
AppsFlyer.addPushNotificationDeepLinkPath({ deepLinkPath }).then(
(res) => console.log(res),
(error) => console.log(error)
);This call matches the following payload structure:
{
...
"deeply": {
"nested": {
"deep_link": "https://yourdeeplink2.onelink.me"
}
}
...
}appendParametersToDeepLinkingURL(params) : Promise<void>
Matches URLs that contain contains as a substring and appends query parameters to them. In case the URL does not match, parameters are not appended to it.
Note:
- The
parametersobject must be consisted ofstringkey andstringvalue - Call this api before calling
AppsFlyer.init() - You must provide the following parameters:
pid,is_retargetingmost be set to'true'
| parameter | type | description |
|---|---|---|
| contains | string | The string to check in URL |
| parameters | Record<string, string> | Parameters to append to the deeplink url after it passed validation |
Example:
AppsFlyer.appendParametersToDeepLinkingURL({
contains: 'substring-of-url',
parameters: { param1: 'value', pid: 'value2', is_retargeting: 'true' },
});setDisableAdvertisingIdentifiers(params) : Promise<void>
Disables collection of various Advertising IDs by the SDK.
Anroid: Google Advertising ID (GAID), OAID and Amazon Advertising ID (AAID)
iOS: Apple's advertisingIdentifier (IDFA)
| parameter | type | description |
|---|---|---|
| disable | boolean | Flag that disable/enable Advertising ID collection |
Example:
AppsFlyer.setDisableAdvertisingIdentifiers({ disable: true });enableTCFDataCollection(params) : Promise<void>
instruct the SDK to collect the TCF data from the device.
| parameter | type | description |
|---|---|---|
| shouldCollect | boolean | enable/disable TCF data collection |
Example:
AppsFlyer.enableTCFDataCollection({ shouldCollect: true });setConsentData(params) : Promise<void>
When GDPR applies to the user and your app does not use a CMP compatible with TCF v2.2/2.3, use this API to provide the consent data directly to the SDK.
Pass a plain object — there is no AppsFlyerConsent constructor class in this plugin's current version:
import AppsFlyer from 'react-native-appsflyer';
// Full consent for GDPR user
const consent1 = { isUserSubjectToGDPR: true, hasConsentForDataUsage: true, hasConsentForAdsPersonalization: true, hasConsentForAdStorage: true };
// No consent for GDPR user
const consent2 = { isUserSubjectToGDPR: true, hasConsentForDataUsage: false, hasConsentForAdsPersonalization: false, hasConsentForAdStorage: false };
// Non-GDPR user
const consent3 = { isUserSubjectToGDPR: false };
AppsFlyer.setConsentData(consent1);Object parameters:
| parameter | type | description |
|---|---|---|
| isUserSubjectToGDPR | boolean | Whether GDPR applies to the user (required) |
| hasConsentForDataUsage | boolean | Consent for data usage (optional) |
| hasConsentForAdsPersonalization | boolean | Consent for ads personalization (optional) |
| hasConsentForAdStorage | boolean | Consent for ad storage (optional) |
isUserSubjectToGDPR is required — there is no client-side default. Omitting it rejects on iOS (its native parser requires the field) or falls back to Android's own native default; TypeScript's SetConsentDataParams type requires it either way, so real callers can't omit it silently.
logAdRevenue(params) : Promise<void>
Use this method to log your ad revenue.
By attributing ad revenue, app owners gain the complete view of user LTV and campaign ROI.
Ad revenue is generated by displaying ads on rewarded videos, offer walls, interstitials, and banners in an app.
| Param | Type |
|---|---|
data |
{ monetizationNetwork, mediationNetwork, currencyIso4217Code, revenue, additionalParameters? } |
Example:
import AppsFlyer, { MEDIATION_NETWORK } from 'react-native-appsflyer';
const adRevenueData = {
monetizationNetwork: 'AF-AdNetwork',
mediationNetwork: MEDIATION_NETWORK.IRONSOURCE,
currencyIso4217Code: 'USD',
revenue: 1.23,
additionalParameters: {
customParam1: 'value1',
customParam2: 'value2',
}
};
AppsFlyer.logAdRevenue(adRevenueData);Note: The additionalParameters object is optional. You can add any additional data you want to log with the ad revenue event in this object. This can be useful for detailed analytics or specific event tracking later on. Make sure that the custom parameters follow the data types and structures specified by AppsFlyer in their documentation.
setMinTimeBetweenSessions(params) : Promise<void>
Set the minimum time that must elapse between app launches for a new session to be counted.
| parameter | type | description |
|---|---|---|
| seconds | number | minimum number of seconds between sessions |
Example:
AppsFlyer.setMinTimeBetweenSessions({ seconds: 10 });setInstallId(params) : Promise<void>
Override the AppsFlyer-generated install ID with a custom identifier.
| parameter | type | description |
|---|---|---|
| installId | string | custom install ID |
Example:
AppsFlyer.setInstallId({ installId: 'custom-install-id' });setDeepLinkTimeout(params) : Promise<void>
Set how long the SDK waits to resolve a deep link before giving up.
| parameter | type | description |
|---|---|---|
| timeout | number | deep link resolution timeout, in milliseconds |
Example:
AppsFlyer.setDeepLinkTimeout({ timeout: 5000 });enableFacebookDeferredApplinks(params) : Promise<void>
Enable or disable resolution of Facebook deferred app links.
| parameter | type | description |
|---|---|---|
| isEnabled | boolean | true to enable Facebook deferred app link resolution |
Example:
AppsFlyer.enableFacebookDeferredApplinks({ isEnabled: true });setCollectAndroidID(params) : Promise<void>
Opt-out of collection of Android ID.
If the app does NOT contain Google Play Services, Android ID is collected by the SDK.
However, apps with Google play services should avoid Android ID collection as this is in violation of the Google Play policy.
| parameter | type | description |
|---|---|---|
| isCollect | boolean | opt-in boolean |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setCollectAndroidID({ isCollect: true });
}Android IMEI-collection opt-out has no RPC equivalent and is removed with no adapter (IMEI collection has also been phased out at the OS level on modern Android versions). See MIGRATION.md.
setDisableNetworkData(params) : Promise<void>
Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.
| parameter | type | description |
|---|---|---|
| isDisable | boolean | Defaults to false. |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setDisableNetworkData({ isDisable: true });
}performDeepLinking(params) : Promise<void>
Enables manual triggering of deep link resolution for a given URL. This method allows apps that are delaying the call to AppsFlyer.start() to resolve deep links before the SDK starts.
Note:
This API will trigger the AppsFlyer.registerDeepLinkListener callback. In the following example, we check if res.status is equal to 'found' inside AppsFlyer.registerDeepLinkListener callback to extract the deeplink parameters.
Same wire method on both platforms, but Android keeps shouldTriggerSession while iOS doesn't take it.
| parameter | type | description |
|---|---|---|
| url | string | the deep link URL to resolve |
| shouldTriggerSession | boolean | Android only; whether resolution should also start a session. Defaults to false. Optional. |
Example:
// Let's say we want the resolve a deeplink and get the deeplink params when the user clicks on it but delay the actual 'start' of the sdk (not sending launch to appsflyer).
const onDeepLink = AppsFlyer.registerDeepLinkListener({
onDeepLinking: (res) => {
if (res.status === 'found') {
// here we will get the deeplink params after resolving it.
// more flow...
}
},
});
AppsFlyer.init({ devKey: 'UsxXxXxed', appId: '75xXxXxXxXx11' });
AppsFlyer.registerSessionReadyListener(() => {
AppsFlyer.start(); // <--- Here we send launch, only once the session is ready
});
if (Platform.OS == 'android') {
AppsFlyer.performDeepLinking({ url: deepLinkUrl, shouldTriggerSession: true });
} else {
AppsFlyer.performDeepLinking({ url: deepLinkUrl });
}
// more app flow...disableAppSetId() : Promise<void>
Disable the collection of AppSet ID.
Must be called before calling start.
Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.disableAppSetId();
AppsFlyer.init({ devKey: 'K2***********99', appId: '41*****44' });
}getHostName() : Promise<string>
Returns the currently configured custom host name (see setHost).
Example:
if (Platform.OS == 'android') {
const hostName = await AppsFlyer.getHostName();
}getHostPrefix() : Promise<string>
Returns the currently configured custom host prefix (see setHost).
Example:
if (Platform.OS == 'android') {
const hostPrefix = await AppsFlyer.getHostPrefix();
}getOutOfStore() : Promise<string>
Returns the currently configured out-of-store source name.
Example:
if (Platform.OS == 'android') {
const outOfStore = await AppsFlyer.getOutOfStore();
}setOutOfStore(params) : Promise<void>
Report an out-of-store source (e.g. an alternative app store) for attribution.
| parameter | type | description |
|---|---|---|
| sourceName | string | the out-of-store source name |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setOutOfStore({ sourceName: 'my-app-store' });
}getAttributionId() : Promise<string>
Returns the Google Play install referrer attribution ID.
Example:
if (Platform.OS == 'android') {
const attributionId = await AppsFlyer.getAttributionId();
}isStopped() : Promise<boolean>
Returns whether the SDK is currently stopped (see stop).
Example:
if (Platform.OS == 'android') {
const stopped = await AppsFlyer.isStopped();
}isPreInstalledApp() : Promise<boolean>
Returns whether the app was pre-installed on the device.
Example:
if (Platform.OS == 'android') {
const isPreInstalled = await AppsFlyer.isPreInstalledApp();
}setLogLevel(params) : Promise<void>
Set the native SDK's log verbosity.
| parameter | type | description |
|---|---|---|
| logLevel | 'none' | 'error' | 'warning' | 'info' | 'debug' | 'verbose' |
the native SDK's log level |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setLogLevel({ logLevel: 'debug' });
}setIsUpdate(params) : Promise<void>
Mark the current install as an update rather than a fresh install (testing aid).
| parameter | type | description |
|---|---|---|
| isUpdate | boolean | true to mark as an update |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setIsUpdate({ isUpdate: true });
}setAppId(params) : Promise<void>
Override the app ID reported to AppsFlyer (for apps whose package name differs from their store listing ID).
| parameter | type | description |
|---|---|---|
| appId | string | the app ID |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setAppId({ appId: 'com.example.app' });
}setPreinstallAttribution(params) : Promise<void>
Report pre-install attribution for apps bundled directly onto a device (OEM deals).
| parameter | type | description |
|---|---|---|
| mediaSource | string | the media source |
| campaign | string | the campaign name |
| siteId | string | the site ID |
Example:
if (Platform.OS == 'android') {
AppsFlyer.setPreinstallAttribution({ mediaSource: 'mediaSource', campaign: 'campaign', siteId: 'siteId' });
}logSession() : Promise<void> — Android only
Explicitly log a new session. Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.logSession();
}onPause() : Promise<void> — Android only
Call when your Activity pauses. Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.onPause();
}collectDataFromLauncherActivity() : Promise<void> — Android only
Collect referrer data from the app's launcher activity. Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.collectDataFromLauncherActivity();
}setDisableCollectASA(params) : Promise<void>
Disables Apple Search Ads collecting
| parameter | type | description |
|---|---|---|
| disable | boolean | Flag to disable/enable Apple Search Ads data collection |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setDisableCollectASA({ disable: true });
}setDisableAppleAdsAttribution(params) : Promise<void>
Disables Apple Ads attribution
| parameter | type | description |
|---|---|---|
| disable | boolean | Flag to disable/enable Apple Ads attribution |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setDisableAppleAdsAttribution({ disable: true });
}setDisableIDFVCollection(params) : Promise<void>
Disables app vendor identifier (IDFV) collection in iOS.
Default is false (the SDK will collect IDFV).
| parameter | type | description |
|---|---|---|
| disable | boolean | Flag to disable/enable IDFV collection |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setDisableIDFVCollection({ disable: true });
}setUseReceiptValidationSandbox(params) : Promise<void>
In app purchase receipt validation Apple environment(production or sandbox). The default value is false.
| parameter | type | description |
|---|---|---|
| sandbox | boolean | true if In app purchase is done with sandbox |
Example:
AppsFlyer.setUseReceiptValidationSandbox({ sandbox: true });setUseUninstallSandbox(params) : Promise<void>
Use the sandbox endpoint for uninstall-token registration.
| parameter | type | description |
|---|---|---|
| sandbox | boolean | true to use the sandbox uninstall-token endpoint |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setUseUninstallSandbox({ sandbox: true });
}setDisableSKAdNetwork(params) : Promise<void>
❗Important❗ setDisableSKAdNetwork must be called before calling init and for iOS ONLY!
| parameter | type | description |
|---|---|---|
| disable | boolean | true if you want to disable SKADNetwork |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setDisableSKAdNetwork({ disable: true });
}setCurrentDeviceLanguage(params) : Promise<void>
Set the language of the device. The data will be displayed in Raw Data Reports
If you want to clear this property, set an empty string. ("")
| parameter | type | description |
|---|---|---|
| language | string | language of the device |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setCurrentDeviceLanguage({ language: 'EN' });
}setShouldCollectDeviceName(params) : Promise<void>
Enable or disable collection of the device's name.
| parameter | type | description |
|---|---|---|
| collect | boolean | true to enable device-name collection |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setShouldCollectDeviceName({ collect: true });
}handleOpenURL(params) : Promise<void> — iOS only
Forwards your app's application(_:open:options:) URL-open event to the native SDK from JS. Most apps get this wired automatically via native AppDelegate code or the Expo config plugin (which auto-injects it at expo prebuild time — see Expo Deep Link Integration); this JS method is the escape hatch for apps that want to forward the event from JS instead. See Deep Linking integration for the native-side call this replaces.
| parameter | type | description |
|---|---|---|
| url | string | the opened URL |
| options | object | iOS open-URL options dictionary. Optional. |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.handleOpenURL({ url, options });
}handleOpenUrl(params) : Promise<void> — iOS only
Same purpose as handleOpenURL — kept as a separate case-variant method to match the native RPC surface.
| parameter | type | description |
|---|---|---|
| url | string | the opened URL |
| options | object | iOS open-URL options dictionary. Optional. |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.handleOpenUrl({ url, options });
}continueUserActivity(params) : Promise<void> — iOS only
Forwards your app's application(_:continue:restorationHandler:) universal-link activity to the native SDK from JS. Most apps get this wired automatically via native AppDelegate code or the Expo config plugin; this JS method is the escape hatch for apps that want to forward the event from JS instead. See Deep Linking integration.
| parameter | type | description |
|---|---|---|
| url | string | the activity's webpageURL |
| activityType | string | the NSUserActivity type. Optional. |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.continueUserActivity({ url });
}handleLaunchOptions(params?) : Promise<void> — iOS only
Forwards your app's cold-start didFinishLaunchingWithOptions payload to the native SDK from JS — needed for cold-start deep link/attribution resolution. Most apps get this wired automatically via native AppDelegate code or the Expo config plugin; this JS method is the escape hatch for apps that want to forward the event from JS instead. See Deep Linking integration.
| parameter | type | description |
|---|---|---|
| launchOptions | object | the launch options dictionary; pass {} if you have nothing to forward. |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.handleLaunchOptions({ launchOptions });
}setFacebookDeferredAppLink(params) : Promise<void>
Explicitly resolve a Facebook deferred app link from the app's open(url:options:) payload.
| parameter | type | description |
|---|---|---|
| url | string | null | the Facebook deferred app link URL |
Example:
if (Platform.OS == 'ios') {
AppsFlyer.setFacebookDeferredAppLink({ url });
}registerConversionListener(callbacks) : Promise<void>
Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking).
Registration is init-order-independent — call it synchronously right after init(), not inside init().then(), so dispatch isn't delayed. See Initialization Flow for the full recommended call order.
Both callbacks are optional on the callbacks object individually, but native's own conversion
listener interface implements both unconditionally on each platform (Android's
AppsFlyerConversionListener has no default implementation for either method; iOS implements
both unconditionally in one delegate conformance), so both fire — pass a no-op for one if you
only care about the other.
| parameter | type | description |
|---|---|---|
| onConversionDataSuccess | function | optional; conversion data result (ConversionData) |
| onConversionDataFail | function | optional; receives the failure |
Example:
AppsFlyer.registerConversionListener({
onConversionDataSuccess: (data) => {
if (data.is_first_launch) {
if (data.af_status === 'Non-organic') {
var media_source = data.media_source;
var campaign = data.campaign;
alert('This is first launch and a Non-Organic install. Media source: ' + media_source + ' Campaign: ' + campaign);
} else if (data.af_status === 'Organic') {
alert('This is first launch and a Organic Install');
}
} else {
alert('This is not first launch');
}
},
onConversionDataFail: (error) => {
console.log(error);
},
});
AppsFlyer.init(/*...*/);Example onConversionDataSuccess payload (ConversionData):
{
"af_status": "Organic",
"is_first_launch": true,
"media_source": "...",
"campaign": "..."
// ...plus any custom params the campaign carries, flattened onto the same object
}The callback receives the conversion data dict directly — not wrapped in a {data, status, type} envelope.
To stop the underlying native listener, call unregisterConversionListener() (Android only — see below).
unregisterConversionListener() : Promise<void>
Stop the native conversion listener and clear all registered callbacks. Android only — iOS has no unregisterConversionListener RPC at all. Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.unregisterConversionListener();
}Both are removed, along with performOnAppAttribution. Attribution data is now delivered
through registerDeepLinkListener instead (documented below), matching what registerConversionListener
already does for deferred deep links. See
MIGRATION.md.
registerDeepLinkListener(callbacks) : Promise<void>
This API is related to DeepLinks. Please read more here
| parameter | type | description |
|---|---|---|
| onDeepLinking | function | optional; UDL data/error callback |
Example:
AppsFlyer.registerDeepLinkListener({
onDeepLinking: (res) => {
if (res.status === 'FOUND') {
const DLValue = res.deepLink?.deep_link_value;
const mediaSrc = res.deepLink?.media_source;
const param1 = res.deepLink?.af_sub1;
console.log(JSON.stringify(res.deepLink, null, 2));
} else if (res.status === 'ERROR') {
console.error(res.error);
}
},
});
AppsFlyer.init(/*...*/);The callback receives a {status, deepLink?, error?} object (status is 'FOUND' | 'NOT_FOUND' | 'ERROR') — see DeepLinkData.
To stop the underlying native listener, call unregisterDeepLinkListener() (Android only — see below).
unregisterDeepLinkListener() : Promise<void>
Stop the native deep-link listener and clear all registered callbacks. Android only. Takes no arguments.
Example:
if (Platform.OS == 'android') {
AppsFlyer.unregisterDeepLinkListener();
}registerSessionReadyListener(callback) : Promise<void>
Fires once the native SDK's session becomes ready to serve attribution/deep-link data. Net-new
in 7.0.0 — no 6.x equivalent. Must be registered synchronously, before init()'s promise
settles — see Initialization Flow.
| parameter | type | description |
|---|---|---|
| callback | function | invoked with no arguments when the session becomes ready |
Example:
AppsFlyer.registerSessionReadyListener(() => {
AppsFlyer.start();
});isSessionReady() : Promise<boolean>
Query whether the native SDK's session is ready to serve attribution/deep-link data. A
one-off Promise query for the current state — not a replacement for
registerSessionReadyListener. Net-new in 7.0.0 — no 6.x
equivalent.
Example:
const ready = await AppsFlyer.isSessionReady();unregisterSessionReadyListener() : Promise<void>
Remove a previously registered session-ready listener. Net-new in 7.0.0 — no 6.x equivalent. Takes no arguments.
Example:
AppsFlyer.unregisterSessionReadyListener();