Skip to content

Latest commit

 

History

History
1304 lines (931 loc) · 41.2 KB

File metadata and controls

1304 lines (931 loc) · 41.2 KB

API

The list of available methods for this plugin is described below.

Table of content

API

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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(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

disableSKAdNetwork

  • iOS only
disableSKAdNetwork(stop: AFDisable) => Promise<void>  

Opt-out of SKAdNetwork

Param Type
stop AFDisable

Returns: Promise

AppsFlyer.disableSKAdNetwork({shouldDisable:true});

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

Param Type
stop AFDisable

Returns: Promise

AppsFlyer.disableAdvertisingIdentifier({shouldDisable:true});

setDisableNetworkData

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});

disableCollectASA

  • 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

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

Set a custom host.

Param Type
hostName AFHost

Returns: Promise

AppsFlyer.setHost({hostName:'ce',hostPrefixName:'af'});

generateInviteLink

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

validateAndLogInAppPurchaseAndroid

  • 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));

validateAndLogInAppPurchaseIos

  • 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

getSdkVersion() => Promise<void>  

Get the AppsFlyer SDK version used in app.

Returns: Promise<AFRes>

AppsFlyer.getSdkVersion()
    .then(v => alert('SDK Version: ' + v.res));

enableFacebookDeferredApplinks

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

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

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

    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

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

Set the user emails and encrypt them.

Param Type
emails AFEmails

Returns: Promise<AFRes>

    AppsFlyer.setUserEmails({emails: ['abc@appsflyer.com', 'af@af.com'], encode: true})
      .then(res => console.log(res.res))
      .catch(e => console.log(e));

logLocation

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

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

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

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

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

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

Interfaces

PluginListenerHandle

Prop Type
remove () => any

OnConversionDataResult

Prop Type
callbackName string
errorMessage string
data any

OnAppOpenAttribution

Prop Type
callbackName string
errorMessage string
data any

OnDeepLink

Prop Type
status string
error string
deepLink any

AFInit

Prop Type
devKey string
appID string
isDebug boolean
waitForATTUserAuthorization number
registerConversionListener boolean
registerOnAppOpenAttribution boolean
registerOnDeepLink boolean
useUninstallSandbox boolean
useReceiptValidationSandbox boolean
minTimeBetweenSessions number
deepLinkTimeout number

AFRes

Prop Type
res string

AFLanguage

Prop Type
language string

AFPhone

Prop Type
phone string

AFEvent

Prop Type
eventName string
eventValue any

AFCuid

Prop Type
cuid string

AFCurrency

Prop Type
currencyCode string

AFUninstall

Prop Type
token string

AFOnelinkID

Prop Type
onelinkID string

AFOnelinkDomain

Prop Type
domains {}

AFAppendToDeepLink

Prop Type
contains string
parameters StringMap

StringMap

AFEmails

Prop Type
emails string[]
encode boolean

AFLatLng

Prop Type
latitude number
longitude number

AFUrls

Prop Type
urls string[]

AFPath

Prop Type
path string[]

AFFilters

Prop Type
filters string[]

AFPartnerData

Prop Type
data any
partnerId string

AFData

Prop Type
additionalData any

AFUid

Prop Type
uid string

AFAnonymizeUser

Prop Type
anonymizeUser boolean

AFStop

Prop Type
stop boolean

AFIsStopped

Prop Type
isStopped boolean

AFDisable

Prop Type
shouldDisable boolean

AFHost

Prop Type
hostPrefixName string
hostName string

AFPromotion

Prop Type
appID string
campaign string
parameters StringMap

AFLinkGenerator

Prop Type
brandDomain string
campaign string
channel string
referrerName string
referrerImageURL string
referrerCustomerId string
baseDeeplink string
addParameters StringMap

AFLink

Prop Type
link string

AFAndroidInAppPurchase

Prop Type
publicKey string
signature string
purchaseData string
price string

AFIosInAppPurchase

Prop Type
inAppPurchase string
price string
transactionId string

AFFbDAL

Prop Type
enableFacebookDAL boolean

AFPushPayload

Prop Type
pushPayload StringMap

AFLogInvite

Prop Type
eventParameters StringMap
channel string

AFEnableTCFDataCollection

Prop Type
shouldEnableTCFDataCollection boolean

AFConsentData

Prop Type
data IAppsFlyerConsent

IAppsFlyerConsent

Prop Type
isUserSubjectToGDPR boolean
hasConsentForDataUsage boolean
hasConsentForAdsPersonalization boolean

Enums

AFConstants

Members Value
onConversionDataSuccess 'onConversionDataSuccess'
onConversionDataFail 'onConversionDataFail'
onAppOpenAttribution 'onAppOpenAttribution'
onAttributionFailure 'onAttributionFailure'
CONVERSION_CALLBACK 'conversion_callback'
OAOA_CALLBACK 'oaoa_callback'
UDL_CALLBACK 'udl_callback'