The list of available methods for this plugin is described below.
addListener - Conversion Data
addListener - onAppOpenAttribution
addListener - onDeepLinking
initSDK
logEvent
setCustomerUserId
setCurrencyCode
updateServerUninstallToken
setAppInviteOneLink
setOneLinkCustomDomain
appendParametersToDeepLinkingURL
setResolveDeepLinkURLs
addPushNotificationDeepLinkPath
setAdditionalData
getAppsFlyerUID
anonymizeUser
stop
disableSKAdNetwork
disableAdvertisingIdentifier
disableCollectASA
setHost
generateInviteLink
validateAndLogInAppPurchaseAndroid
validateAndLogInAppPurchaseIos
getSdkVersion
enableFacebookDeferredApplinks
sendPushNotificationData
setCurrentDeviceLanguage
logCrossPromoteImpression
setUserEmails
logLocation
setPhoneNumber
setPartnerData
logInvite
setDisableNetworkData
setSharingFilterForPartners
setSharingFilter
- DeprecatedsetSharingFilterForAllPartners
- DeprecatedstartSDK
- Since 6.13.0enableTCFDataCollection
- Since 6.13.0setConsentData
- Since 6.13.0logAdRevenue
- Since 6.15.0
addListener(eventName: AFConstants.CONVERSION_CALLBACK, listenerFunc: (event: OnConversionDataResult) => void) => PluginListenerHandle
Param | Type |
---|---|
eventName |
AFConstants.CONVERSION_CALLBACK |
listenerFunc |
(event: OnConversionDataResult) => void |
Returns: PluginListenerHandle
Example:
AppsFlyer.addListener(AFConstants.CONVERSION_CALLBACK, event => {
alert('CONVERSION_CALLBACK ~~>' + JSON.stringify(event));
if (event.callbackName === AFConstants.onConversionDataSuccess) {
console.log(AFConstants.onConversionDataSuccess);
} else {
console.log(AFConstants.onConversionDataFail);
}
});
See also Deferred Deep Linking guide here.
addListener(eventName: AFConstants.OAOA_CALLBACK, listenerFunc: (event: OnAppOpenAttribution) => void) => PluginListenerHandle
Param | Type |
---|---|
eventName |
AFConstants.OAOA_CALLBACK |
listenerFunc |
(event: OnAppOpenAttribution) => void |
Returns: PluginListenerHandle
AppsFlyer.addListener(AFConstants.OAOA_CALLBACK, res => {
alert('OAOA_CALLBACK ~~>' + JSON.stringify(res));
if (res.callbackName === AFConstants.onAppOpenAttribution) {
console.log(AFConstants.onAppOpenAttribution);
} else {
console.log(AFConstants.onAttributionFailure);
}
});
See also Direct Deep Linking guide here.
addListener(eventName: AFConstants.UDL_CALLBACK, listenerFunc: (event: OnDeepLink) => void) => PluginListenerHandle
Param | Type |
---|---|
eventName |
AFConstants.UDL_CALLBACK |
listenerFunc |
(event: OnDeepLink) => void |
Returns: PluginListenerHandle
AppsFlyer.addListener(AFConstants.UDL_CALLBACK, res => {
alert('UDL_CALLBACK ~~>' + JSON.stringify(res));
if (res.status === 'FOUND') {
console.log('deep link found');
} else if (res.status === 'ERROR') {
console.log('deep link error');
}else{
console.log('deep link not found');
}
});
See also Unified Deeplinking guide here.
initSDK(options: AFInit) => Promise<AFRes>
Use this method to initialize and start AppsFlyer SDK. This API should be called as soon as the app launched.
Param | Type |
---|---|
options |
AFInit |
Returns: Promise<AFRes>
const options: AFInit = {
appID: '1234567890', // replace with your app ID.
devKey: 'your_dev_key', // replace with your dev key.
isDebug: true,
waitForATTUserAuthorization: 10, // for iOS 14 and higher
registerOnDeepLink: true,
registerConversionListener: true,
};
AppsFlyer.initSDK(options)
.then(res => alert(JSON.stringify(res)))
.catch(e =>alert(e));
See also Init SDK guide here.
startSDK(): Promise<AFRes>;
Use this method to start AppsFlyer SDK only on manual start mode.
Returns: Promise<AFRes>
Usage Example:
AppsFlyer.startSDK()
.then(res => console.log("AppsFlyer SDK Start Response: ", res.res))
.catch(err => console.error("AppsFlyer SDK Start Error: ", err));
logEvent(data: AFEvent) => Promise<AFRes>
Log an in-app event.
Param | Type |
---|---|
data |
AFEvent |
Returns: Promise<AFRes>
const data: AFEvent = {
eventName: 'test',
eventValue: {
af_revenue: 956,
af_receipt_id: 'id536',
af_currency: 'USD'
}
};
AppsFlyer.logEvent(data)
.then(r => alert('logEvent ~~>' + r.res))
.catch(err => alert('logEvent err ~~>' + err));
See also Log Event guide here.
setCustomerUserId(cuid: AFCuid) => Promise<void>
Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and other devices’ IDs.
This ID is available in raw-data reports and in the Postback APIs for cross-referencing with your internal IDs.
Param | Type |
---|---|
cuid |
AFCuid |
Returns: Promise
AppsFlyer.setCustomerUserId({cuid: 'your_cuid_here'});
setCurrencyCode(currencyCode: AFCurrency) => Promise<void>
Sets the currency for in-app purchases. The currency code should be a 3 character ISO 4217 code
Param | Type |
---|---|
currencyCode |
AFCurrency |
Returns: Promise
AppsFlyer.setCurrencyCode({currencyCode: 'ILS'});
updateServerUninstallToken(token: AFUninstall) => Promise<void>
(Android) Allows to pass GCM/FCM Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for Uninstall log.
(iOS) Allows to pass APN Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for log Uninstall.
Param | Type |
---|---|
token |
AFUninstall |
Returns: Promise
AppsFlyer.updateServerUninstallToken({token: 'replace_with_token'});
See also Uninstall guide here.
setAppInviteOneLink(id: AFOnelinkID) => Promise<void>
Set the OneLink ID that should be used for attributing user-Invite. The link that is generated for the user invite will use this OneLink as the base link.
Param | Type |
---|---|
id |
AFOnelinkID |
Returns: Promise
AppsFlyer.setAppInviteOneLink({onelinkID: 'ymod'});
setOneLinkCustomDomain(domains: AFOnelinkDomain) => Promise<void>
In order for AppsFlyer SDK to successfully resolve hidden (decoded in shortlink ID) attribution parameters, any domain that is configured as a branded domain in the AppsFlyer Dashboard should be provided to this method.
Param | Type |
---|---|
domains |
AFOnelinkDomain |
Returns: Promise
AppsFlyer.setOneLinkCustomDomain({domains:
['promotion.greatapp.com', 'click.greatapp.com', 'deals.greatapp.com']});
appendParametersToDeepLinkingURL(data: AFAppendToDeepLink) => Promise<void>
Enables app owners using App Links for deep linking (without OneLink) to attribute sessions initiated via a domain associated with their app. Call this method before calling start.
You must provide the following parameters in the parameters Map:
pid
is_retargeting must be set to true
Param | Type |
---|---|
data |
AFAppendToDeepLink |
Returns: Promise
AppsFlyer.appendParametersToDeepLinkingURL({
contains: 'appsflyer',
parameters: {
is_retargeting: 'true', //Required
pid: 'af_plugin', //Required
my_param: 'xyz'
}
});
setResolveDeepLinkURLs(urls: AFUrls) => Promise<void>
Advertisers can wrap an AppsFlyer OneLink within another Universal Link. This Universal Link will invoke the app but any deep linking data will not propagate to AppsFlyer.
setResolveDeepLinkURLs enables you to configure the SDK to resolve the wrapped OneLink URLs, so that deep linking can occur correctly.
Param | Type |
---|---|
urls |
AFUrls |
Returns: Promise
AppsFlyer.setResolveDeepLinkURLs({urls: ['af', 'appsflyer']});
addPushNotificationDeepLinkPath(path: AFPath) => Promise<void>
Configures how the SDK extracts deep link values from push notification payloads.
Param | Type |
---|---|
path |
AFPath |
Returns: Promise
AppsFlyer.addPushNotificationDeepLinkPath({path: ['appsflyer', 'capacitor', 'plugin']});
More info can be found here.
setSharingFilterForPartners(filters: AFFilters) => Promise<void>
Stops events from propagating to the specified AppsFlyer partners.
Param | Type |
---|---|
filters |
AFFilters |
Returns: Promise
AppsFlyer.setSharingFilterForPartners({filters: ['google_int']}); // set filter for spesific partners
AppsFlyer.setSharingFilterForPartners({filters: ['all']}); // set filters for spesific partners
AppsFlyer.setSharingFilterForPartners({filters: ['None']}); // remove all filters
setSharingFilter(filters: AFFilters) => Promise<void>
Stops events from propagating to the specified AppsFlyer partners.
Param | Type |
---|---|
filters |
AFFilters |
Returns: Promise
AppsFlyer.setSharingFilter({filters: ['google_int']});
setSharingFilterForAllPartners() => Promise<void>
Stops events from propagating to all AppsFlyer partners. Overwrites setSharingFilter.
Returns: Promise
AppsFlyer.setSharingFilterForAllPartners();
setAdditionalData(additionalData: AFData) => Promise<void>
Set additional data to be sent to AppsFlyer. See
Param | Type |
---|---|
additionalData |
AFData |
Returns: Promise
AppsFlyer.setAdditionalData({
additionalData: {
capacitor: 'plugin',
apps: 'Flyer'
}
});
getAppsFlyerUID() => Promise<void>
Get AppsFlyer's unique device ID (created for every new install of an app).
Returns: Promise
AppsFlyer.getAppsFlyerUID()
.then(res => alert('AppsFlyer ID:' + res.uid));
anonymizeUser(anonymize: AFAnonymizeUser) => Promise<void>
End User Opt-Out from AppsFlyer analytics (Anonymize user data).
Param | Type |
---|---|
anonymize |
AFAnonymizeUser |
Returns: Promise
AppsFlyer.anonymizeUser({anonymizeUser: true});
stop(stop?: AFStop | undefined) => Promise<void>
Once this API is invoked, our SDK no longer communicates with our servers and stops functioning.
Useful when implementing user opt-in/opt-out.
Param | Type |
---|---|
stop |
AFStop |
Returns: Promise
AppsFlyer.stop({stop: true}) //change state
.then(r => alert('isStopped: ' + r.isStopped)); //show state after change
- iOS only
disableSKAdNetwork(stop: AFDisable) => Promise<void>
Opt-out of SKAdNetwork
Param | Type |
---|---|
stop |
AFDisable |
Returns: Promise
AppsFlyer.disableSKAdNetwork({shouldDisable:true});
disableAdvertisingIdentifier(stop: AFDisable) => Promise<void>
Disables collection of various Advertising IDs by the SDK. This includes Apple Identity for Advertisers (IDFA), Google Advertising ID (GAID), OAID and Amazon Advertising ID (AAID).
Param | Type |
---|---|
stop |
AFDisable |
Returns: Promise
AppsFlyer.disableAdvertisingIdentifier({shouldDisable:true});
setDisableNetworkData(disable: AFDisable) => Promise<void>
Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device. (Android Only)
Param | Type |
---|---|
disable |
AFDisable |
Returns: Promise
AppsFlyer.setDisableNetworkData({shouldDisable:true});
- iOS only
disableCollectASA(stop: AFDisable) => Promise<void>
Opt-out of Apple Search Ads attributions.
Param | Type |
---|---|
stop |
AFDisable |
Returns: Promise
AppsFlyer.disableCollectASA({shouldDisable:true});
setHost(hostName: AFHost) => Promise<void>
Set a custom host.
Param | Type |
---|---|
hostName |
AFHost |
Returns: Promise
AppsFlyer.setHost({hostName:'ce',hostPrefixName:'af'});
generateInviteLink(params: AFLinkGenerator) => Promise<void>
Allowing your existing users to invite their friends and contacts as new users to your app
Param | Type |
---|---|
params |
AFLinkGenerator |
Returns: Promise
AppsFlyer.generateInviteLink({
addParameters: {code: '1256abc', page: '152'},
campaign: 'appsflyer_plugin',
channel: 'sms'
})
.then(r => alert('user invite link: ' + r.link))
.catch(e => alert('user invite error: ' + e));
- Android only
validateAndLogInAppPurchaseAndroid(purchaseData: AFAndroidInAppPurchase) => Promise<void>
API for server verification of in-app purchases. An af_purchase event with the relevant values will be automatically logged if the validation is successful.
Param | Type |
---|---|
purchaseData |
AFAndroidInAppPurchase |
Returns: Promise<
AFRes>
AppsFlyer.validateAndLogInAppPurchaseAndroid({
additionalParameters: {aa: 'cc'},
currency: 'usd',
price: '20',
signature: 'the_signature',
publicKey: 'your_public_key',
purchaseData: 'the_purchase_data'
})
.then(r => alert('validateAndLogInAppPurchase success: ' + r.res))
.catch(e => alert('validateAndLogInAppPurchase error: ' + e));
- iOS only
validateAndLogInAppPurchaseIos(purchaseData: AFIosInAppPurchase) => Promise<void>
Param | Type |
---|---|
purchaseData |
AFIosInAppPurchase |
Returns: Promise<AFRes>
AppsFlyer.validateAndLogInAppPurchaseIos({
additionalParameters: {aa: 'cc'},
currency: 'usd',
price: '20',
inAppPurchase: 'productIdentifier',
transactionId: 'transactionId'
})
.then(r => alert('validateAndLogInAppPurchase success: ' + r.res))
.catch(e => alert('validateAndLogInAppPurchase error: ' + JSON.stringify(e)));
getSdkVersion() => Promise<void>
Get the AppsFlyer SDK version used in app.
Returns: Promise<AFRes>
AppsFlyer.getSdkVersion()
.then(v => alert('SDK Version: ' + v.res));
enableFacebookDeferredApplinks(enable: AFFbDAL) => Promise<void>
Enable the collection of Facebook Deferred AppLinks. Requires Facebook SDK and Facebook app on target/client device.
This API must be invoked before initializing the AppsFlyer SDK in order to function properly.
Param | Type |
---|---|
enable |
AFFbDAL |
Returns: Promise<AFRes>
AppsFlyer.enableFacebookDeferredApplinks({enableFacebookDAL: true})
.then(res => alert(res.res))
.catch(e => alert(e));
sendPushNotificationData(payload: AFPushPayload) => Promise<void>
Measure and get data from push-notification campaigns.
Param | Type |
---|---|
payload |
AFPushPayload |
Returns: Promise
AppsFlyer.sendPushNotificationData({
pushPayload: {af: '{"pid":"media_int","is_retargeting":"true", "c":"test_campaign"}'} //replace with push payload
});
setCurrentDeviceLanguage(language: AFLanguage): Promise<AFRes>;
Set the language of the device. The data will be displayed in Raw Data Reports
Param | Type |
---|---|
language |
AFLanguage |
Returns: Promise
AppsFlyer.setCurrentDeviceLanguage({language: 'en'})
.then(res => console.log(res.res))
.catch(e => console.log(e));
logCrossPromoteImpression(data: AFPromotion): Promise<AFRes>;
logs an impression as part of a cross-promotion campaign. Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard.
Param | Type |
---|---|
data |
AFPromotion |
Returns: Promise
if (isPlatform('ios')) {
AppsFlyer.logCrossPromoteImpression({
appID: 'id1192323960',
campaign: 'test',
parameters: {pid: 'capacitorTest', deep_link_value: 'af'}
});
} else {
AppsFlyer.logCrossPromoteImpression({
appID: 'com.appsflyer.android.deviceid',
campaign: 'test',
parameters: {pid: 'capacitorTest', deep_link_value: 'af'}
});
}
setUserEmails(emails: AFEmails): Promise<AFRes>;
Set the user emails and encrypt them.
Param | Type |
---|---|
emails |
AFEmails |
Returns: Promise<AFRes>
AppsFlyer.setUserEmails({emails: ['[email protected]', '[email protected]'], encode: true})
.then(res => console.log(res.res))
.catch(e => console.log(e));
logLocation(latLng : AFLatLng): Promise<AFRes>;
Manually log the location of the user
Param | Type |
---|---|
latLng |
AFLatLng |
Returns: Promise<AFRes>
AppsFlyer.logLocation({latitude: -32.25562, longitude: 32.545414})
.then(res => console.log(res.res))
.catch(e => console.log(e));
setPhoneNumber(phone : AFPhone): Promise<AFRes>;
Will be sent as an SHA-256 encrypted string.
Param | Type |
---|---|
phone |
AFPhone |
Returns: Promise<AFRes>
AppsFlyer.setPhoneNumber({phone: '0123456789'})
.then(res => console.log(res.res))
.catch(e => console.log(e));
setPartnerData(data : AFPartnerData): Promise<AFRes>;
Allows sending custom data for partner integration purposes.
Param | Type |
---|---|
data |
AFPartnerData |
Returns: Promise<AFRes>
AppsFlyer.setPartnerData({
data: {
apps: 'flyer',
af: 'IL'
},
partnerId: 'af_int'
}).then(res => console.log(res.res))
.catch(e => console.log(e));
logInvite(data : AFLogInvite): Promise<AFRes>;
Use to log a user-invite in-app event (af_invite).
Param | Type |
---|---|
data |
AFLogInvite |
Returns: Promise<AFRes>
AppsFlyer.logInvite({channel: 'email', eventParameters: {abc: 'xyz', apps: 'Flyer'}})
.then(res => console.log(res.res))
.catch(e => console.log(e));
enableTCFDataCollection(shouldEnableTCFDataCollection: AFEnableTCFDataCollection): Promise<void>
Use to opt-in/out the automatic collection of consent data, for users who use a CMP. Flag value will be persisted between app sessions.
Param | Type |
---|---|
shouldEnableTCFDataCollection |
AFEnableTCFDataCollection |
Returns: Promise
Usage Example:
AppsFlyer.enableTCFDataCollection({shouldEnableTCFDataCollection : <true/false>})
setConsentData(data : AFConsentData): Promise<void>
Use to set user consent data manualy. if your app doesn't use a CMP compatible with TCF v2.2, use the following method to manualy provide the consent data directly to the SDK.
Param | Type |
---|---|
data |
AFConsentData |
Returns: Promise
Usage Example: If GDPR doesn’t to the user, perform the following:
AppsFlyer.setConsentData({data: AppsFlyerConsent.forNonGDPRUser()})
If GDPR applies apply to the user perform the following:
AppsFlyer.setConsentData({data : AppsFlyerConsent.forGDPRUser(<true/false>, <true/false>)});
Please take a look how to properly setConsentData Manualy in Set Consent For DMA Compliance
logAdRevenue(data: AFAdRevenueData): 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 |
AFAdRevenueData |
Returns: Promise
Usage Example:
const myAdditionalParams = {
spong: 'bob',
doctor: 'who'
};
const data: AFAdRevenueData = {
monetizationNetwork: "MoneyMoneyMoney",
mediationNetwork: MediationNetwork.IRONSOURCE,
currencyIso4217Code: "USD",
revenue: 200.0,
additionalParameters: myAdditionalParams
};
AppsFlyer.logAdRevenue(data);
Prop | Type |
---|---|
remove |
() => any |
Prop | Type |
---|---|
callbackName |
string |
errorMessage |
string |
data |
any |
Prop | Type |
---|---|
callbackName |
string |
errorMessage |
string |
data |
any |
Prop | Type |
---|---|
status |
string |
error |
string |
deepLink |
any |
Prop | Type |
---|---|
devKey |
string |
appID |
string |
isDebug |
boolean |
waitForATTUserAuthorization |
number |
registerConversionListener |
boolean |
registerOnAppOpenAttribution |
boolean |
registerOnDeepLink |
boolean |
useUninstallSandbox |
boolean |
useReceiptValidationSandbox |
boolean |
minTimeBetweenSessions |
number |
deepLinkTimeout |
number |
Prop | Type |
---|---|
res |
string |
Prop | Type |
---|---|
language |
string |
Prop | Type |
---|---|
phone |
string |
Prop | Type |
---|---|
eventName |
string |
eventValue |
any |
Prop | Type |
---|---|
cuid |
string |
Prop | Type |
---|---|
currencyCode |
string |
Prop | Type |
---|---|
token |
string |
Prop | Type |
---|---|
onelinkID |
string |
Prop | Type |
---|---|
domains |
{} |
Prop | Type |
---|---|
contains |
string |
parameters |
StringMap |
Prop | Type |
---|---|
emails |
string[] |
encode |
boolean |
Prop | Type |
---|---|
latitude |
number |
longitude |
number |
Prop | Type |
---|---|
urls |
string[] |
Prop | Type |
---|---|
path |
string[] |
Prop | Type |
---|---|
filters |
string[] |
Prop | Type |
---|---|
data |
any |
partnerId |
string |
Prop | Type |
---|---|
additionalData |
any |
Prop | Type |
---|---|
uid |
string |
Prop | Type |
---|---|
anonymizeUser |
boolean |
Prop | Type |
---|---|
stop |
boolean |
Prop | Type |
---|---|
isStopped |
boolean |
Prop | Type |
---|---|
shouldDisable |
boolean |
Prop | Type |
---|---|
hostPrefixName |
string |
hostName |
string |
Prop | Type |
---|---|
appID |
string |
campaign |
string |
parameters |
StringMap |
Prop | Type |
---|---|
brandDomain |
string |
campaign |
string |
channel |
string |
referrerName |
string |
referrerImageURL |
string |
referrerCustomerId |
string |
baseDeeplink |
string |
addParameters |
StringMap |
Prop | Type |
---|---|
link |
string |
Prop | Type |
---|---|
publicKey |
string |
signature |
string |
purchaseData |
string |
price |
string |
Prop | Type |
---|---|
inAppPurchase |
string |
price |
string |
transactionId |
string |
Prop | Type |
---|---|
enableFacebookDAL |
boolean |
Prop | Type |
---|---|
pushPayload |
StringMap |
Prop | Type |
---|---|
eventParameters |
StringMap |
channel |
string |
Prop | Type |
---|---|
shouldEnableTCFDataCollection |
boolean |
Prop | Type |
---|---|
data |
IAppsFlyerConsent |
Prop | Type |
---|---|
isUserSubjectToGDPR |
boolean |
hasConsentForDataUsage |
boolean |
hasConsentForAdsPersonalization |
boolean |
Prop | Type |
---|---|
monetizationNetwork |
string |
mediationNetwork |
MediationNetwork |
currencyIso4217Code |
string |
revenue |
number |
additionalParameters? |
StringMap |
Members | Value |
---|---|
onConversionDataSuccess |
'onConversionDataSuccess' |
onConversionDataFail |
'onConversionDataFail' |
onAppOpenAttribution |
'onAppOpenAttribution' |
onAttributionFailure |
'onAttributionFailure' |
CONVERSION_CALLBACK |
'conversion_callback' |
OAOA_CALLBACK |
'oaoa_callback' |
UDL_CALLBACK |
'udl_callback' |
Members | Value |
---|---|
IRONSOURCE |
'ironsource' |
APPLOVIN_MAX |
'applovinmax' |
GOOGLE_ADMOB |
'googleadmob' |
FYBER |
'fyber' |
APPODEAL |
'appodeal' |
ADMOST |
'Admost' |
TOPON |
'Topon' |
TRADPLUS |
'Tradplus' |
YANDEX |
'Yandex' |
CHARTBOOST |
'chartboost' |
UNITY |
'Unity' |
TOPON_PTE |
'toponpte' |
CUSTOM_MEDIATION |
'customMediation' |
DIRECT_MONETIZATION_NETWORK |
'directMonetizationNetwork' |