API参考

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


Android, iOS and Windows API

initSDK

void initSDK(string devKey, string appID, MonoBehaviour gameObject)

Initialize the AppsFlyer SDK with the devKey and appID.
The dev key is required for all apps and the appID is required only for iOS.
If you app is for Android only pass null for the appID.

parametertypedescription
dev_keystringAppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard.
app_idstringYour app's Apple ID.
gameObject (可选)MonoBehaviourThe game object containing the IAppsFlyerConversionData interface.

示例:

AppsFlyer.initSDK("dev_key", "app_id"); // without deeplinking
AppsFlyer.initSDK("dev_key", "app_id", this); // with deeplinking

Note : You only need to implement the SDK with deeplinking if you are using the IAppsFlyerConversionData interface.


startSDK

void startSDK()

Once this API is invoked the SDK will start, sessions will be immediately sent, and all background foreground transitions will record a session.

示例:

 AppsFlyer.startSDK();

Android and iOS API

stopSDK

void stopSDK(bool isSDKStopped)

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.

如需重新激活SDK,请调用同一个API,将其设为false。

Important :
Do not call startSDK() if stopSDK() is set to true.

To restart SDK functions again, use the following API:

AppsFlyer.stopSDK(false);

警告
Use the stopSDK API only in cases where you want to fully ignore the user's SDK functions. Using this API SEVERELY impacts your attribution, data collection and deep linking mechanism.

parametertypedescription
isSDKStoppedboolTrue if the SDK is stopped (default value is false).

示例:

AppsFlyer.stopSDK(true);

isSDKStopped

bool isSDKStopped()

Was the stopSDK(boolean) API set to true.

示例:

if (!AppsFlyer.isSDKStopped())
{
  
}

getSdkVersion

string getSdkVersion()

Get the AppsFlyer SDK version used in the app.

示例:

string version = AppsFlyer.getSdkVersion();

setIsDebug

void setIsDebug(bool shouldEnable)

启用AppsFlyer SDK的调试日志。

警告
Only set to true in development / debug.

parametertypedescription
shouldEnableboolTrue if debug mode is on (default is false)

示例:

AppsFlyer.setIsDebug(true);

addPushNotificationDeepLinkPath

void addPushNotificationDeepLinkPath(params string[] paths)

添加密钥数组,用于组建密钥路径,用于解析推送通知有效载荷的深度链接。

parametertypedescription
pathsstring[]array of strings that represent the key path to the deeplink in the push notification payload

示例:

用法示例
Basic configuration:

AppsFlyer.addPushNotificationDeepLinkPath("af_push_link")

此调用方法可匹配以下调用方法:

{
  "af_push_link": "https://yourdeeplink2.onelink.me"
}

ֿAdvanced configuration:

string[] paths = {"deeply", "nested", "deep_link"};
AppsFlyer.addPushNotificationDeepLinkPath(paths);

此调用方法可匹配以下调用方法:

{
  "deeply": {
      "nested": {
          "deep_link": "https://yourdeeplink2.onelink.me"
      }
  }
}

setCustomerUserId

void setCustomerUserId(string id)

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 your internal IDs.

parametertypedescription
idstringcustom user ID

示例:

AppsFlyer.setCustomerUserId("custom_user_id");

setAppInviteOneLinkID

void setAppInviteOneLinkID(string oneLinkId)

Set the OneLink ID that should be used for User-Invite-API
The link that is generated for the user invite will use this OneLink as the base link.

parametertypedescription
oneLinkIdstringOneLink ID for User-Invite attribution

示例:

AppsFlyer.setAppInviteOneLinkID("abcd");

setAdditionalData

void setAdditionalData(Dictionary<string, string> customData)

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.

parametertypedescription
customDataDictionary<string, string>additional data

示例:

Dictionary<string, string> customData = new Dictionary<string, string>();
customData.Add("custom1", "someData");
AppsFlyer.setAdditionalData(customData);

setResolveDeepLinkURLs

void setResolveDeepLinkURLs(params string[] urls)

If you are using OneLinks which support Android App Links and wrapping them with a 3rd Party Universal Link, you can use the setResolveDeepLinkURLs API to notify the AppsFlyer SDK which click domains that invoke the app should be resolved by the SDK and have the underlying OneLink extracted from them. This will allow you to maintain deep linking and attribution while wrapping the OneLink with a 3rd party Universal Link. Make sure to call this API before SDK initialization.

parametertypedescription
urlsparams string[]array of urls

示例:

AppsFlyer.setResolveDeepLinkURLs("test.com", "test2.ca");

setOneLinkCustomDomain

void setOneLinkCustomDomain(params string[] domains)

Advertisers can use this method to set vanity onelink domains.

parametertypedescription
domainsparams string[]array of custom domains

示例:

 AppsFlyer.setOneLinkCustomDomain("test.domain", "test2.domain");

setCurrencyCode

void setCurrencyCode(string currencyCode)

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.

parametertypedescription
currencyCodestring3 character ISO 4217 code. (default is USD)

示例:

AppsFlyer.setCurrencyCode("GBP");


setDeepLinkTimeout

void setDeepLinkTimeout(long deepLinkTimeout)

Setting the deepLink timeout value that should be used for DDL.
If you want to use it, set it before the DDL setting.

parametertypedescription
deepLinkTimeoutlongin milliseconds

示例:

AppsFlyer.setDeepLinkTimeout(2000);

enableTCFDataCollection

void enableTCFDataCollection(bool shouldCollectTcfData)

Calling enableTCFDataCollection(true) will enable collecting and sending any TCF related data.
Calling enableTCFDataCollection(false) will disable the collection of TCF related data and from sending it.

parametertypedescription
shouldCollectTcfDatabooltrue to enable data collection

示例:

AppsFlyer.enableTCFDataCollection(true);;

setConsentData

void setConsentData(AppsFlyerConsent appsFlyerConsent)

Sets or updates the user consent data related to GDPR and DMA regulations for advertising and data usage purposes within the application.

parametertypedescription
appsFlyerConsentAppsFlyerConsentInstance of AppsFlyerConsent class

示例:

AppsFlyerConsent consent = AppsFlyerConsent.ForGDPRUser(false, false);
AppsFlyer.setConsentData(consent);

recordLocation

void recordLocation(double latitude, double longitude)

Manually record the location of the user.

parametertypedescription
latitudedoublelatitude of user
longitudedoublelongitude of user

示例:

AppsFlyer.recordLocation(40.7128, 74.0060);

anonymizeUser

void anonymizeUser(bool shouldAnonymizeUser)

AppsFlyer provides you with a method to anonymize specific user identifiers in AppsFlyer analytics. This method complies with the latest privacy requirements and complies with Facebook data and privacy policies. Default is NO, meaning no anonymization is performed by default.
Use this API during the SDK Initialization to explicitly anonymize a user's installs, events and sessions.
You can cancel anonymization by calling anonymizeUser again, set to false.

警告
对用户匿名会严重影响您的归因信息。
只在法律要求您不得收集用户信息的地区使用此选项。

parametertypedescription
shouldAnonymizeUserbooltrue to perform anonymization

示例:

AppsFlyer.anonymizeUser(true);

getAppsFlyerId

string getAppsFlyerId()

AppsFlyer's unique device ID is created for every new install of an app. Use the following API to obtain AppsFlyer’s Unique ID.

示例:

string uid = AppsFlyer.getAppsFlyerId(); 

setMinTimeBetweenSessions

void setMinTimeBetweenSessions(int seconds)

By default, at least 5 seconds must lapse between 2 app launches to count as separate 2 sessions (more about counting sessions). However, you can use the following API to set your custom value for the minimum required time between sessions.

Note: Setting a high value to the custom time between launches may badly impact APIs relying on sessions data, such as deep linking.

parametertypedescription
secondsinttime between sessions (default is 5 seconds)

示例:

AppsFlyer.setMinTimeBetweenSessions(4);

setHost

void setHost(string hostPrefixName, string hostName)

设置自定义主机。

parametertypedescription
hostPrefixNamestring
hostNamestring

示例:

AppsFlyer.setHost("hostPrefixName","hostName");

setUserEmails

void setUserEmails(EmailCryptType cryptMethod, params string[] emails)

设置用户电子邮件并对其进行加密。

cryptMethod Encryption methods:
EmailCryptType.EmailCryptTypeSHA256
EmailCryptType.EmailCryptTypeNone

parametertypedescription
cryptMethodEmailCryptTypenone, or sha256
emailsparams string[]list of emails

示例:

AppsFlyer.setUserEmails(EmailCryptType.EmailCryptTypeSHA256, "[email protected]", "[email protected]");

setPhoneNumber

void setPhoneNumber(string phoneNumber)

Set the user phone number.

parametertypedescription
phoneNumberstring

示例:

AppsFlyer.setPhoneNumber("4166358181");

getConversionData

void getConversionData(string objectName);

Register a Conversion Data Listener.
Allows the developer to access the user attribution data in real-time for every new install, directly from the SDK level.
By doing this you can serve users with personalized content or send them to specific activities within the app,
which can greatly enhance their engagement with your app.

Get the callbacks by implementing the IAppsFlyerConversionData interface.

parametertypedescription
objectNamestringgame object with the IAppsFlyerConversionData interface

示例:

AppsFlyer.getConversionData(gameObject.name);

attributeAndOpenStore

void attributeAndOpenStore(string appID, string campaign, Dictionary<string, string> userParams, MonoBehaviour gameObject)

Use the following API to attribute the click and launch the app store's app page.

Get the callbacks by implementing the IAppsFlyerUserInvite interface.

parametertypedescription
appIDstring
campaignstring
userParamsDictionary<string, string>
gameObjectMonoBehaviourgame object with the IAppsFlyerUserInvite interface

示例:

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("af_sub1", "val");
parameters.Add("custom_param", "val2");
AppsFlyer.attributeAndOpenStore("123456789", "test campaign", parameters, this);

logAdRevenue

void logAdRevenue(AFAdRevenueData adRevenueData, Dictionary<string, string> additionalParameters)

Logs ad revenue data along with additional parameters if provided.

parametertypedescription
adRevenueDataAFAdRevenueDataInstance of AFAdRevenueData containing ad revenue information
additionalParametersDictionary<string, string> An optional map of additional parameters to be logged with ad revenue data

示例:

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("value1", "5");
parameters.Add(AdRevenueScheme.COUNTRY, "USA");
var logRevenue = new AFAdRevenueData("monetizationNetworkEx", MediationNetwork.GoogleAdMob, "USD", 0.99);
AppsFlyer.logAdRevenue(logRevenue, parameters);

recordCrossPromoteImpression

void recordCrossPromoteImpression(string appID, string campaign);

To attribute an impression use the following API call.
Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard.

parametertypedescription
appIDstringApp ID
campaignstringcampaign
paramsDictionary<string, string>additional params

示例:

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("af_sub1", "val");
parameters.Add("custom_param", "val2");
AppsFlyer.recordCrossPromoteImpression("appID", "campaign", parameters);

generateUserInviteLink

void generateUserInviteLink(Dictionary<string, string> parameters, MonoBehaviour gameObject)

The LinkGenerator class builds the invite URL according to various setter methods which allow passing on additional information on the click.
See - https://support.appsflyer.com/hc/en-us/articles/115004480866-User-invite-attribution-

parametertypedescription
parametersDictionary<string, string>
gameObjectMonoBehaviourgame object with the IAppsFlyerUserInvite interface

示例:

AppsFlyer.generateUserInviteLink(params, this);

setSharingFilterForAllPartners Deprecated

void setSharingFilterForAllPartners()

Used by advertisers to exclude all networks/integrated partners from getting data.

示例:

AppsFlyer.setSharingFilterForAllPartners();

setSharingFilter Deprecated

void setSharingFilter(params string[] partners)

Used by advertisers to set some (one or more) networks/integrated partners to exclude from getting data.

parametertypedescription
partnersparams string[] partnerspartners to exclude from getting data

示例:

AppsFlyer.setSharingFilter("googleadwords_int","snapchat_int","doubleclick_int");

setSharingFilterForPartners

void setSharingFilterForPartners(params string[] partners)

Used by advertisers to set some (one or more) networks/integrated partners to exclude from getting data.

parametertypedescription
partnersparams string[] partnerspartners to exclude from getting data

示例:

AppsFlyer.setSharingFilterForPartners("partner1_int"); // Single partner
AppsFlyer.setSharingFilterForPartners("partner1_int", "partner2_int"); // Multiple partners
AppsFlyer.setSharingFilterForPartners("all"); // All partners
AppsFlyer.setSharingFilterForPartners(""); // Reset list (default)
AppsFlyer.setSharingFilterForPartners(); // Reset list (default)

setPartnerData

void setPartnerData(string partnerID, params string[] partnerInfo)

允许为合作伙伴的对接目的发送自定义数据。

parametertypedescription
partnerIDstring渠道的ID(通常以“_int”为后缀)。
partnerInfoparams string[]客户数据,取决于渠道的具体对接配置。

示例:

   Dictionary<string, string> partnerInfo = new Dictionary<string, string>();
        partnerInfo.Add("puid", "1234567890");
        AppsFlyer.setPartnerData("partner_test", partnerInfo);

Android Only API

updateServerUninstallToken

void updateServerUninstallToken(string token)

Manually pass the Firebase Device Token for Uninstall measurement.

parametertypedescription
tokenstringFirebase FCM token

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.updateServerUninstallToken("token");
#endif

setImeiData

void setImeiData(string imei)

By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat (4.4)
and the device contains Google Play Services(on SDK versions 4.8.8 and below the specific app needed GPS).
Use this API to explicitly send IMEI to AppsFlyer.

parametertypedescription
imeistringdevice's IMEI

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setImeiData("imei");
#endif

setAndroidIdData

void setAndroidIdData(string androidId)

By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat(4.4)and the device contains Google Play Services(on SDK versions 4.8.8 and below the specific app needed GPS).
Use this API to explicitly send Android ID to AppsFlyer.

parametertypedescription
androidIdstringdevice's Android ID

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setAndroidIdData("androidId");
#endif

waitForCustomerUserId

void waitForCustomerUserId(bool wait)

It is possible to delay the SDK Initialization until the customerUserID is set.
This feature makes sure that the SDK doesn't begin functioning until the customerUserID is provided.
If this API is used, all in-app events and any other SDK API calls are discarded, until the customerUserID is provided.

parametertypedescription
waitboolTrue if you want the SDK to wait for customerUserID

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.waitForCustomerUserId(true);
#endif

setCustomerIdAndStartSDK

void setCustomerIdAndStartSDK(string id)

⚠️

Before calling this method, the method waitForCustomerUserId must be called

Use this API to provide the SDK with the relevant customer user id and trigger the SDK to begin its normal activity.

parametertypedescription
idstring客户的客户ID。

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setCustomerIdStartSDK("id");
#endif

getOutOfStore

string getOutOfStore()

用于获取当前的AF_STORE值。

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        string af_store = AppsFlyer.getOutOfStore();
#endif

setOutOfStore

void setOutOfStore(string sourceName)

用于手动设置AF_STORE值。

parametertypedescription
sourceNamestring

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setOutOfStore("sourceName");
#endif

setCollectAndroidID

void setCollectAndroidID(bool isCollect)

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.

parametertypedescription
isCollectbool

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setCollectAndroidID(true);
#endif

setCollectIMEI

void setCollectIMEI(bool isCollect)

Opt-out of collection of IMEI.
If the app does NOT contain Google Play Services, device IMEI is collected by the SDK.
However, apps with Google play services should avoid IMEI collection as this is in violation of the Google Play policy.

parametertypedescription
isCollectbool

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setCollectIMEI(true);
#endif

setIsUpdate

void setIsUpdate(bool isUpdate)

手动设置应用程序已更新。

parametertypedescription
isUpdatebooltrue if app was updated

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setIsUpdate(true);
#endif

setPreinstallAttribution

void setPreinstallAttribution(string mediaSource, string campaign, string siteId)

指定预安装归因的制造商或媒体渠道名称。

parametertypedescription
mediaSourcestring预安装归因的制造商或媒体渠道名称。
campaignstring预安装归因的营销活动名称。
siteIdstring预安装归因的网站ID。

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setPreinstallAttribution("mediaSource", "campaign", "siteId");
#endif

isPreInstalledApp

bool isPreInstalledApp()

制造商预安装的布尔指标。

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        if (AppsFlyer.isPreInstalledApp())
        {

        }
#endif

handlePushNotifications

void handlePushNotifications()
When the handlePushNotifications API is called push notifications will be recorded.

示例:

AppsFlyer.handlePushNotifications();

getAttributionId

string getAttributionId()

获取Facebook的归因ID(如果存在)。

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        string attributionId = AppsFlyer.getAttributionId();
#endif

validateAndSendInAppPurchase-beta

void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, string> additionalParameters, MonoBehaviour gameObject)

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

parametertypedescription
detailsAFPurchaseDetailsAndroidInstance of AFPurchaseDetailsAndroid class
additionalParametersDictionary<string, string>parameters to be sent with the purchase.
gameObjectMonoBehaviourGame object for the callbacks to be sent

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AFPurchaseDetailsAndroid details = new AFPurchaseDetailsAndroid(AFPurchaseType.Subscription, 
        "token", "productId", "price", "currency");
        
        AppsFlyer.validateAndSendInAppPurchase(
        details, 
        null, 
        this);
#endif

validateAndSendInAppPurchase

void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)

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

parametertypedescription
publicKeystring从Google Play控制台获得的许可证密钥。
signaturestringdata.INAPP_DATA_SIGNATURE.
purchaseDatastringdata.INAPP_PURCHASE_DATA
pricestringPurchase price
currencystring预安装归因的网站ID。
additionalParametersDictionary<string, string>parameters to be sent with the purchase.
gameObjectMonoBehaviourGame object for the callbacks to be sent

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.validateAndSendInAppPurchase(
        "publicKey", 
        "signature", 
        "purchaseData", 
        "price", 
        "currency", 
        null, 
        this);
#endif

setCollectOaid

void setCollectOaid(boolean isCollect)

setCollectOaid

You must include the appsflyer oaid library for this api to work.
parametertypedescription
isCollectbooltrue to allow oaid collection

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setCollectOaid(true);
#endif

setDisableAdvertisingIdentifiers

void setDisableAdvertisingIdentifiers(boolean disable)

setDisableAdvertisingIdentifiers

Disables collection of various Advertising IDs by the SDK. This includes Google Advertising ID (GAID), OAID and Amazon Advertising ID (AAID)
parametertypedescription
disablebooltrue to disable

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setDisableAdvertisingIdentifiers(true);
#endif


setDisableNetworkData

void setDisableNetworkData(boolean disable)

setDisableNetworkData

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

示例:

#if UNITY_ANDROID && !UNITY_EDITOR
        AppsFlyer.setDisableNetworkData(true);
#endif

iOS Only API

setDisableCollectAppleAdSupport

void setDisableCollectAppleAdSupport(bool disable)

AppsFlyer SDK collects Apple's advertisingIdentifier if the AdSupport.framework is included in the SDK.
You can disable this behavior by setting the following property to true.

parametertypedescription
disablebool

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.setDisableCollectAppleAdSupport(true);
#endif

handlePushNotifications(iOS)

void handlePushNotification(Dictionary<string, string> pushPayload)
When the handlePushNotifications API is called from a service that is swizzling, like Firebase, the push notifications payload will be handled by the AppsflyerSDK.

parametertypedescription
pushPayloadDictionary<string, string>the push notification payload

示例:

#if UNITY_IOS && !UNITY_EDITOR
    // e.Message.Data = push notification payload
    var dataDict = new Dictionary<string, string>(e.Message.Data);
    AppsFlyeriOS.handlePushNotification(dataDict);
#endif

setShouldCollectDeviceName

void setShouldCollectDeviceName(bool shouldCollectDeviceName)

Set this flag to true, to collect the current device name(e.g. "My iPhone"). Default value is false.

parametertypedescription
shouldCollectDeviceNamebool

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.setShouldCollectDeviceName(true);
#endif

setDisableCollectIAd

void setDisableCollectIAd(bool disableCollectIAd)

用于停止ASA归因。

parametertypedescription
disableCollectIAdbool

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.setDisableCollectIAd(true);
#endif

setUseReceiptValidationSandbox

void setUseReceiptValidationSandbox(bool useReceiptValidationSandbox)

In app purchase receipt validation Apple environment(production or sandbox). The default value is false.

parametertypedescription
useReceiptValidationSandboxbooltrue if In app purchase is done with sandbox

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.setUseReceiptValidationSandbox(true);
#endif

setUseUninstallSandbox

void setUseUninstallSandbox(bool useUninstallSandbox)

Set this flag to test uninstall on Apple environment(production or sandbox). The default value is false.

parametertypedescription
useUninstallSandboxbooltrue if you are using a APN certificate

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.setUseUninstallSandbox(true);
#endif

validateAndSendInAppPurchase-beta-iOS

void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> extraEventValues, MonoBehaviour gameObject)

To send and validate in app purchases you can call this method from the processPurchase method.

parametertypedescription
detailsAFSDKPurchaseDetailsIOSInstance of AFSDKPurchaseDetailsIOS class.
extraEventValuesDictionary<string, string>The additional param, which you want to receive it in the raw reports.
gameObjectMonoBehaviourthe game object for the

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AFSDKPurchaseDetailsIOS details = AFSDKPurchaseDetailsIOS.Init("productId", "price", "currency",
        "transactionId");
        AppsFlyer.validateAndSendInAppPurchase(
        details, 
        null, 
        this);
#endif

validateAndSendInAppPurchase

void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)

To send and validate in app purchases you can call this method from the processPurchase method.

parametertypedescription
productIdentifierstringThe product identifier.
pricestringThe product price.
currencystringThe product currency.
tranactionIdstringThe purchase transaction Id.
additionalParametersDictionary<string, string>The additional param, which you want to receive it in the raw reports.
gameObjectMonoBehaviourthe game object for the callbacks

示例:

#if UNITY_IOS && !UNITY_EDITOR
        AppsFlyer.validateAndSendInAppPurchase(
        "productIdentifier", 
        "price", 
        "currency", 
        "tranactionId", 
        null, 
        this);
#endif

registerUninstall

void registerUninstall(byte[] deviceToken)

注册卸载 - 您应该注册远程通知并为AppsFlyer提供推送设备令牌。

parametertypedescription
deviceTokenbyte[]APN token

示例:

    private bool tokenSent;

    void Update()
    {
#if UNITY_IOS && !UNITY_EDITOR
        if (!tokenSent)
        {
            byte[] token = UnityEngine.iOS.NotificationServices.deviceToken;
            if (token != null)
            {
                AppsFlyer.registerUninstall(token);
                tokenSent = true;
            }
        }
#endif
    }


handleOpenUrl

void handleOpenUrl(string url, string sourceApplication, string annotation)

In case you want to track deep linking manually call handleOpenUrl.
The continueUserActivity and onOpenURL are implemented in the AppsFlyerAppController.mm class, so 
only use this method if the other methods do not cover your apps deeplinking needs.
parametertypedescription
urlstringThe URL to be passed to your AppDelegate
sourceApplicationstringThe sourceApplication to be passed to your AppDelegate
annotationstringThe annotation to be passed to your app delegate

示例:

#if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.handleOpenUrl(string url, string sourceApplication, string annotation);
#endif

waitForATTUserAuthorizationWithTimeoutInterval

void waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval)

See here for more info.

parametertypedescription
timeoutIntervalintTime to wait for idfa

示例:

#if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60);
#endif

disableSKAdNetwork

bools disableSKAdNetwork(bool isDisabled)

parametertypedescription
isDisabledboolTrue to disable SKAdNetwork

示例:

#if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.disableSKAdNetwork(true);
#endif

setLanguage

setCurrentDeviceLanguage(string language)

parametertypedescription
languageStringThe language to set

示例:

#if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.setCurrentDeviceLanguage("english");
#endif

disableIDFVCollection

disableIDFVCollection(bool isDisabled)

parametertypedescription
isDisabledboolTrue to disable IDFV collection

示例:

#if UNITY_IOS && !UNITY_EDITOR
    AppsFlyer.disableIDFVCollection(true);
#endif

IAppsFlyerConversionData

onConversionDataSuccess

public void onConversionDataSuccess(string conversionData)

ConversionData contains information about install.
Organic/non-organic, etc. See here for more info.

parametertypedescription
conversionDatastringJSON string of the returned conversion data

示例:

   public void onConversionDataSuccess(string conversionData)
    {
        AppsFlyer.AFLog("onConversionDataSuccess", conversionData);
        Dictionary<string, object> conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
        // add deferred deeplink logic here
    }

onConversionDataFail

public void onConversionDataFail(string error)

parametertypedescription
errorstringA string describing the error

示例:

    public void onConversionDataFail(string error)
    {
        AppsFlyer.AFLog("onConversionDataFail", error);
    }

onAppOpenAttribution

public void onAppOpenAttribution(string attributionData)

attributionData contains information about OneLink, deeplink.

parametertypedescription
attributionDatastringJSON string of the returned deeplink data

示例:

    public void onAppOpenAttribution(string attributionData)
    {
        AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
        Dictionary<string, object> attributionDataDictionary = AppsFlyer.CallbackStringToDictionary(attributionData);
        // add direct deeplink logic here
    }

onAppOpenAttributionFailure

public void onAppOpenAttributionFailure(string error)

Any errors that occurred during the attribution request.

parametertypedescription
errorstringstring describing the error

示例:

  public void onAppOpenAttributionFailure(string error)
    {
        AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
    }

IAppsFlyerUserInvite

onInviteLinkGenerated

public void onInviteLinkGenerated(string link)

The success callback for generating OneLink URLs.

parametertypedescription
linkstringgenerated link

示例:

   public void onInviteLinkGenerated(string link)
    {

    }

onInviteLinkGeneratedFailure

public void onInviteLinkGeneratedFailure(string error)

The error callback for generating OneLink URLs

parametertypedescription
errorstringA string describing the error

示例:

    public void onInviteLinkGeneratedFailure(string error)
    {
        AppsFlyer.AFLog("onInviteLinkGeneratedFailure", error);
    }

onOpenStoreLinkGenerated

public void onOpenStoreLinkGenerated(string link)

(ios only) iOS allows you to utilize the StoreKit component to open
the App Store while remaining in the context of your app.

More details at here

parametertypedescription
attributionDatastringJSON string of the returned deeplink data

示例:

    public void onOpenStoreLinkGenerated(string link)
    {

    }

IAppsFlyerValidateReceipt

didFinishValidateReceipt

public void didFinishValidateReceipt(string result)

The success callback for validateAndSendInAppPurchase API.

For Android : the callback will return "Validate success".

For iOS : the callback will return a JSON string from apples verifyReceipt API.

parametertypedescription
resultstringvalidate result

示例:

   public void didFinishValidateReceipt(string link)
    {

    }

IAppsFlyerValidateAndLog

onValidateAndLogComplete

public void didFinishValidateReceipt(string result)

The success callback for validateAndSendInAppPurchase API.

The callback will return a JSON string which can be converted to dictionary.

parametertypedescription
resultstringvalidate result

示例:

   public void onValidateAndLogComplete(string result)
    {
        AppsFlyer.AFLog("onValidateAndLogComplete", result);
        Dictionary<string, object> validateAndLogDataDictionary = AppsFlyer.CallbackStringToDictionary(result);
    }

onValidateAndLogFailure

public void onValidateAndLogFailure(string error)

The error callback for validating receipts.

The callback will return a JSON string which can be converted to dictionary.

parametertypedescription
errorstringA string describing the error

示例:

    public void onValidateAndLogFailure(string error)
    {
         AppsFlyer.AFLog("onValidateAndLogFailure", error); 
    }

事件

onRequestResponse

public static event EventHandler OnRequestResponse

The callback for Sessions.

statusCodeerrorDescription
200null
10"事件超时,检查'minTimeBetweenSessions'参数"
11“正在跳过事件,因为启用了'isStopTracking'”
40网络错误:错误说明来自Android
41“没有dev key”
50"Status code failure"(状态码错误)+ 实际服务器响应码

示例:

    AppsFlyer.OnRequestResponse += (sender, args) =>
    {
        var af_args = args as AppsFlyerRequestEventArgs;
        AppsFlyer.AFLog("AppsFlyerOnRequestResponse", "status code" + af_args.statusCode);
    };

onInAppResponse

public static event EventHandler OnInAppResponse

The callback for In-App Events.

statusCodeerrorDescription
200null
10"事件超时,检查'minTimeBetweenSessions'参数"
11“正在跳过事件,因为启用了'isStopTracking'”
40网络错误:错误说明来自Android
41“没有dev key”
50"Status code failure"(状态码错误)+ 实际服务器响应码

示例:


    AppsFlyer.OnInAppResponse += (sender, args) =>
    {
        var af_args = args as AppsFlyerRequestEventArgs;
        AppsFlyer.AFLog("OnRequestResponse", "status code" + af_args.statusCode);
    }; 


onDeepLinkReceived

public static event EventHandler OnDeepLinkReceived

The callback for Unified Deeplink API.

示例:


    // First call init with devKey, appId and gameObject
    AppsFlyer.initSDK(devKey, appID, this);


    AppsFlyer.OnDeepLinkReceived += (sender, args) =>
    {
        var deepLinkEventArgs = args as DeepLinkEventsArgs;

        // DEEPLINK LOGIC HERE
    };