@capgo/capacitor-appsflyer

June 16, 2026 · View on GitHub

Capgo - Instant updates for Capacitor

➡️ Get Instant updates for your App with Capgo

Missing a feature? We’ll build the plugin for you 💪

AppsFlyer attribution and deep-linking support for Capacitor 8 apps, packaged in Capgo's plugin layout with CocoaPods and Swift Package Manager support.

This package is based on the official AppsFlyer Capacitor plugin and the Capacitor 8 / SPM update work from AppsFlyerSDK/appsflyer-capacitor-plugin#185.

Edit: the Capacitor 8 has been resolved you can now consider this fork deprecated.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/appsflyer/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8..v8..

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-appsflyer` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add @capgo/capacitor-appsflyer
bunx cap sync

Usage

import { AppsFlyer, AFConstants } from '@capgo/capacitor-appsflyer';

AppsFlyer.addListener(AFConstants.CONVERSION_CALLBACK, (event) => {
  console.log('AppsFlyer conversion event', event);
});

await AppsFlyer.initSDK({
  devKey: 'YOUR_DEV_KEY',
  appID: 'YOUR_IOS_APP_ID',
  registerConversionListener: true,
  registerOnDeepLink: true,
});

Call initSDK() as early as possible during app startup. Use manualStart: true if you want to separate initialization from startSDK().

Notes

  • appID is required for iOS and should match your Apple App Store numeric app ID.
  • Deep link callbacks are emitted through Capacitor listeners using the AFConstants channel names exported by the package.
  • disableSKAdNetwork() is iOS-only and disableAppSetId() is Android-only.

API

addListener(AFConstants.CONVERSION_CALLBACK, ...)

addListener(eventName: AFConstants.CONVERSION_CALLBACK, listenerFunc: (event: OnConversionDataResult) => void) => PluginListenerHandle
ParamType
eventNameAFConstants.CONVERSION_CALLBACK
listenerFunc(event: OnConversionDataResult) => void

Returns: PluginListenerHandle


addListener(AFConstants.OAOA_CALLBACK, ...)

addListener(eventName: AFConstants.OAOA_CALLBACK, listenerFunc: (event: OnAppOpenAttribution) => void) => PluginListenerHandle
ParamType
eventNameAFConstants.OAOA_CALLBACK
listenerFunc(event: OnAppOpenAttribution) => void

Returns: PluginListenerHandle


addListener(AFConstants.UDL_CALLBACK, ...)

addListener(eventName: AFConstants.UDL_CALLBACK, listenerFunc: (event: OnDeepLink) => void) => PluginListenerHandle
ParamType
eventNameAFConstants.UDL_CALLBACK
listenerFunc(event: OnDeepLink) => void

Returns: PluginListenerHandle


initSDK(...)

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.

ParamType
optionsAFInit

Returns: Promise<AFRes>


startSDK()

startSDK() => Promise<AFRes>

Use this method to start AppsFlyer SDK, only on manual start mode.

Returns: Promise<AFRes>


logEvent(...)

logEvent(data: AFEvent) => Promise<AFRes>

Log an in-app event.

ParamType
dataAFEvent

Returns: Promise<AFRes>


setCustomerUserId(...)

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.

ParamType
cuidAFCuid

setCurrencyCode(...)

setCurrencyCode(currencyCode: AFCurrency) => Promise<void>

Sets the currency for in-app purchases. The currency code should be a 3 character ISO 4217 code

ParamType
currencyCodeAFCurrency

updateServerUninstallToken(...)

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.

ParamType
tokenAFUninstall

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.

ParamType
idAFOnelinkID

setOneLinkCustomDomain(...)

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.

ParamType
domainsAFOnelinkDomain

appendParametersToDeepLinkingURL(...)

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

ParamType
dataAFAppendToDeepLink

setResolveDeepLinkURLs(...)

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.

ParamType
urlsAFUrls

addPushNotificationDeepLinkPath(...)

addPushNotificationDeepLinkPath(path: AFPath) => Promise<void>

Configures how the SDK extracts deep link values from push notification payloads.

ParamType
pathAFPath

setSharingFilter(...)

setSharingFilter(filters: AFFilters) => Promise<void>

Stops events from propagating to the specified AppsFlyer partners.

ParamType
filtersAFFilters

setSharingFilterForAllPartners()

setSharingFilterForAllPartners() => Promise<void>

Stops events from propagating to all AppsFlyer partners. Overwrites setSharingFilter.


setSharingFilterForPartners(...)

setSharingFilterForPartners(filters: AFFilters) => Promise<void>

Stops events from propagating to the specified AppsFlyer partners.

ParamType
filtersAFFilters

setAdditionalData(...)

setAdditionalData(additionalData: AFData) => Promise<void>

Set additional data to be sent to AppsFlyer. See

ParamType
additionalDataAFData

getAppsFlyerUID()

getAppsFlyerUID() => Promise<AFUid>

Get AppsFlyer's unique device ID (created for every new install of an app).

Returns: Promise<AFUid>


anonymizeUser(...)

anonymizeUser(anonymize: AFAnonymizeUser) => Promise<void>

End User Opt-Out from AppsFlyer analytics (Anonymize user data).

ParamType
anonymizeAFAnonymizeUser

stop(...)

stop(stop?: AFStop | undefined) => Promise<AFIsStopped>

Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. Useful when implementing user opt-in/opt-out.

ParamType
stopAFStop

Returns: Promise<AFIsStopped>


disableSKAdNetwork(...)

disableSKAdNetwork(stop: AFDisable) => Promise<void>

Opt-out of SKAdNetwork

ParamType
stopAFDisable

disableAdvertisingIdentifier(...)

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).

ParamType
stopAFDisable

disableCollectASA(...)

disableCollectASA(stop: AFDisable) => Promise<void>

Opt-out of Apple Search Ads attributions.

ParamType
stopAFDisable

setHost(...)

setHost(hostName: AFHost) => Promise<void>

Set a custom host.

ParamType
hostNameAFHost

generateInviteLink(params: AFLinkGenerator) => Promise<AFLink>

Allowing your existing users to invite their friends and contacts as new users to your app

ParamType
paramsAFLinkGenerator

Returns: Promise<AFLink>


validateAndLogInAppPurchaseAndroid(...)

validateAndLogInAppPurchaseAndroid(purchaseData: AFAndroidInAppPurchase) => Promise<AFRes>

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.

ParamType
purchaseDataAFAndroidInAppPurchase

Returns: Promise<AFRes>


validateAndLogInAppPurchaseIos(...)

validateAndLogInAppPurchaseIos(purchaseData: AFIosInAppPurchase) => Promise<AFRes>
ParamType
purchaseDataAFIosInAppPurchase

Returns: Promise<AFRes>


getSdkVersion()

getSdkVersion() => Promise<AFRes>

Get the AppsFlyer SDK version used in app.

Returns: Promise<AFRes>


enableFacebookDeferredApplinks(enable: AFFbDAL) => Promise<AFRes>

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.

ParamType
enableAFFbDAL

Returns: Promise<AFRes>


sendPushNotificationData(...)

sendPushNotificationData(payload: AFPushPayload) => Promise<void>

Measure and get data from push-notification campaigns.

ParamType
payloadAFPushPayload

setCurrentDeviceLanguage(...)

setCurrentDeviceLanguage(language: AFLanguage) => Promise<AFRes>

Set the language of the device. The data will be displayed in Raw Data Reports

ParamType
languageAFLanguage

Returns: Promise<AFRes>


logCrossPromoteImpression(...)

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.

ParamType
dataAFPromotion

Returns: Promise<AFRes>


setUserEmails(...)

setUserEmails(emails: AFEmails) => Promise<AFRes>

Set the user emails and encrypt them.

ParamType
emailsAFEmails

Returns: Promise<AFRes>


logLocation(...)

logLocation(latLng: AFLatLng) => Promise<AFRes>

Manually log the location of the user

ParamType
latLngAFLatLng

Returns: Promise<AFRes>


setPhoneNumber(...)

setPhoneNumber(phone: AFPhone) => Promise<AFRes>

Will be sent as an SHA-256 encrypted string.

ParamType
phoneAFPhone

Returns: Promise<AFRes>


setPartnerData(...)

setPartnerData(data: AFPartnerData) => Promise<AFRes>

Allows sending custom data for partner integration purposes.

ParamType
dataAFPartnerData

Returns: Promise<AFRes>


logInvite(...)

logInvite(data: AFLogInvite) => Promise<AFRes>

Use to log a user-invite in-app event (af_invite).

ParamType
dataAFLogInvite

Returns: Promise<AFRes>


setDisableNetworkData(...)

setDisableNetworkData(disable: AFDisable) => Promise<void>

Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.

ParamTypeDescription
disableAFDisableDefaults to false

enableTCFDataCollection(...)

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.

ParamType
shouldEnableTCFDataCollectionAFEnableTCFDataCollection

setConsentData(...)

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.

ParamTypeDescription
dataAFConsentData: AppsFlyerConsent object.

logAdRevenue(...)

logAdRevenue(data: AFAdRevenueData) => Promise<void>

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. You can use this method to log your ad revenue.

ParamType
dataAFAdRevenueData

setConsentDataV2(...)

setConsentDataV2(options: AFConsentOptions) => Promise<void>

Use this 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.

ParamTypeDescription
optionsAFConsentOptions: AFConsentOptions that consists with all the possible options for consent collection, boolean params.

isSDKStarted()

isSDKStarted() => Promise<AFIsStarted>

Use this method to check whether the AppsFlyer SDK has already been started in the current session.

Returns: Promise<AFIsStarted>


isSDKStopped()

isSDKStopped() => Promise<AFIsStopped>

Use this method to check whether the AppsFlyer SDK is currently stopped.

Returns: Promise<AFIsStopped>


disableAppSetId()

disableAppSetId() => Promise<void>

Disables AppSet ID collection. If called before SDK init, App Set ID will not be collected. If called after init, App Set ID will be collected but not sent in request payloads. Android only.


validateAndLogInAppPurchaseV2(...)

validateAndLogInAppPurchaseV2(data: AFPurchaseDetailsV2) => Promise<{ [key: string]: any; }>

API for server verification of in-app purchases V2. An af_purchase event with the relevant values will be automatically logged if the validation is successful.

ParamTypeDescription
dataAFPurchaseDetailsV2- Object containing purchaseDetails and optional additionalParameters

Returns: Promise<{ [key: string]: any; }>


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>

OnConversionDataResult

PropType
callbackNamestring
errorMessagestring
dataany

OnAppOpenAttribution

PropType
callbackNamestring
errorMessagestring
dataany
PropType
statusstring
errorstring
deepLinkany

AFRes

PropType
resstring

AFInit

PropType
devKeystring
appIDstring
isDebugboolean
waitForATTUserAuthorizationnumber
registerConversionListenerboolean
registerOnAppOpenAttributionboolean
registerOnDeepLinkboolean
useUninstallSandboxboolean
useReceiptValidationSandboxboolean
minTimeBetweenSessionsnumber
deepLinkTimeoutnumber
manualStartboolean

AFEvent

PropType
eventNamestring
eventValueany

AFCuid

PropType
cuidstring

AFCurrency

PropType
currencyCodestring

AFUninstall

PropType
tokenstring

AFOnelinkID

PropType
onelinkIDstring

AFOnelinkDomain

PropType
domainsstring[]
PropType
containsstring
parametersStringMap

StringMap

AFUrls

PropType
urlsstring[]

AFPath

PropType
pathstring[]

AFFilters

PropType
filtersstring[]

AFData

PropType
additionalDataany

AFUid

PropType
uidstring

AFAnonymizeUser

PropType
anonymizeUserboolean

AFIsStopped

PropType
isStoppedboolean

AFStop

PropType
stopboolean

AFDisable

PropType
shouldDisableboolean

AFHost

PropType
hostPrefixNamestring
hostNamestring
PropType
linkstring

AFLinkGenerator

PropType
brandDomainstring
campaignstring
channelstring
referrerNamestring
referrerImageURLstring
referrerCustomerIdstring
baseDeeplinkstring
addParametersStringMap

AFAndroidInAppPurchase

PropType
publicKeystring
signaturestring
purchaseDatastring
pricestring

AFIosInAppPurchase

PropType
inAppPurchasestring
pricestring
transactionIdstring

AFFbDAL

PropType
enableFacebookDALboolean

AFPushPayload

PropType
pushPayloadStringMap

AFLanguage

PropType
languagestring

AFPromotion

PropType
appIDstring
campaignstring
parametersStringMap

AFEmails

PropType
emailsstring[]
encodeboolean

AFLatLng

PropType
latitudenumber
longitudenumber

AFPhone

PropType
phonestring

AFPartnerData

PropType
dataany
partnerIdstring

AFLogInvite

PropType
eventParametersStringMap
channelstring

AFEnableTCFDataCollection

PropType
shouldEnableTCFDataCollectionboolean

AFConsentData

PropType
dataIAppsFlyerConsent

IAppsFlyerConsent

PropType
isUserSubjectToGDPRboolean
hasConsentForDataUsageboolean
hasConsentForAdsPersonalizationboolean

AFAdRevenueData

PropType
monetizationNetworkstring
mediationNetworkMediationNetwork
currencyIso4217Codestring
revenuenumber
additionalParametersStringMap

AFConsentOptions

PropType
isUserSubjectToGDPRboolean | null
hasConsentForDataUsageboolean | null
hasConsentForAdsPersonalizationboolean | null
hasConsentForAdStorageboolean | null

AFIsStarted

PropType
isStartedboolean

AFPurchaseDetailsV2

PropType
purchaseDetailsAFPurchaseDetails
additionalParametersStringMap

AFPurchaseDetails

PropType
purchaseTypeAFPurchaseType
purchaseTokenstring
productIdstring

Enums

AFConstants

MembersValue
onConversionDataSuccess'onConversionDataSuccess'
onConversionDataFail'onConversionDataFail'
onAppOpenAttribution'onAppOpenAttribution'
onAttributionFailure'onAttributionFailure'
CONVERSION_CALLBACK'conversion_callback'
OAOA_CALLBACK'oaoa_callback'
UDL_CALLBACK'udl_callback'

MediationNetwork

MembersValue
IRONSOURCE'ironsource'
APPLOVIN_MAX'applovin_max'
GOOGLE_ADMOB'google_admob'
FYBER'fyber'
APPODEAL'appodeal'
ADMOST'admost'
TOPON'topon'
TRADPLUS'tradplus'
YANDEX'yandex'
CHARTBOOST'chartboost'
UNITY'unity'
TOPON_PTE'topon_pte'
CUSTOM_MEDIATION'custom_mediation'
DIRECT_MONETIZATION_NETWORK'direct_monetization_network'

AFPurchaseType

MembersValue
oneTimePurchase'one_time_purchase'
subscription'subscription'