API参考
The list of available methods for this plugin is described below.
- Android, iOS and Windows API
- Android and iOS API
- stopSDK
- isSDKStopped
- getSdkVersion
- setIsDebug
- addPushNotificationDeepLinkPath
- setCustomerUserId
- setAppInviteOneLinkID
- setAdditionalData
- setResolveDeepLinkURLs
- setOneLinkCustomDomain
- setCurrencyCode
- setDeepLinkTimeout
- enableTCFDataCollection
- setConsentData
- recordLocation
- anonymizeUser
- getAppsFlyerId
- setMinTimeBetweenSessions
- setHost
- setUserEmails
- setPhoneNumber
- getConversionData
- attributeAndOpenStore
- logAdRevenue
- recordCrossPromoteImpression
- generateUserInviteLink
- setSharingFilterForAllPartners Deprecated
- setSharingFilter Deprecated
- setSharingFilterForPartners
- setPartnerData
- Android Only API
- updateServerUninstallToken
- setImeiData
- setAndroidIdData
- waitForCustomerUserId
- setCustomerIdAndStartSDK
- getOutOfStore
- setOutOfStore
- setCollectAndroidID
- setCollectIMEI
- setIsUpdate
- setPreinstallAttribution
- isPreInstalledApp
- handlePushNotifications
- getAttributionId
- validateAndSendInAppPurchase-beta
- validateAndSendInAppPurchase
- setCollectOaid
- setDisableAdvertisingIdentifiers
- setDisableNetworkData
- iOS Only API
- setDisableCollectAppleAdSupport
- handlePushNotifications(iOS)
- setShouldCollectDeviceName
- setDisableCollectIAd
- setUseReceiptValidationSandbox
- setUseUninstallSandbox
- validateAndSendInAppPurchase-beta-iOS
- validateAndSendInAppPurchase
- registerUninstall
- handleOpenUrl
- waitForATTUserAuthorizationWithTimeoutInterval
- disableSKAdNetwork
- setLanguage
- disableIDFVCollection
- IAppsFlyerConversionData
- IAppsFlyerUserInvite
- IAppsFlyerValidateReceipt
- IAppsFlyerValidateAndLog
- 事件
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.
parameter | type | description |
---|---|---|
dev_key | string | AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. |
app_id | string | Your app's Apple ID. |
gameObject (可选) | MonoBehaviour | The 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.
parameter | type | description |
---|---|---|
isSDKStopped | bool | True 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.
parameter | type | description |
---|---|---|
shouldEnable | bool | True if debug mode is on (default is false) |
示例:
AppsFlyer.setIsDebug(true);
addPushNotificationDeepLinkPath
void addPushNotificationDeepLinkPath(params string[] paths)
添加密钥数组,用于组建密钥路径,用于解析推送通知有效载荷的深度链接。
parameter | type | description |
---|---|---|
paths | string[] | 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.
parameter | type | description |
---|---|---|
id | string | custom 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.
parameter | type | description |
---|---|---|
oneLinkId | string | OneLink 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.
parameter | type | description |
---|---|---|
customData | Dictionary<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.
parameter | type | description |
---|---|---|
urls | params 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.
parameter | type | description |
---|---|---|
domains | params 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.
parameter | type | description |
---|---|---|
currencyCode | string | 3 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.
parameter | type | description |
---|---|---|
deepLinkTimeout | long | in 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.
parameter | type | description |
---|---|---|
shouldCollectTcfData | bool | true 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.
parameter | type | description |
---|---|---|
appsFlyerConsent | AppsFlyerConsent | Instance 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.
parameter | type | description |
---|---|---|
latitude | double | latitude of user |
longitude | double | longitude 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.
警告
对用户匿名会严重影响您的归因信息。
只在法律要求您不得收集用户信息的地区使用此选项。
parameter | type | description |
---|---|---|
shouldAnonymizeUser | bool | true 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.
parameter | type | description |
---|---|---|
seconds | int | time between sessions (default is 5 seconds) |
示例:
AppsFlyer.setMinTimeBetweenSessions(4);
setHost
void setHost(string hostPrefixName, string hostName)
设置自定义主机。
parameter | type | description |
---|---|---|
hostPrefixName | string | |
hostName | string |
示例:
AppsFlyer.setHost("hostPrefixName","hostName");
setUserEmails
void setUserEmails(EmailCryptType cryptMethod, params string[] emails)
设置用户电子邮件并对其进行加密。
cryptMethod Encryption methods:
EmailCryptType.EmailCryptTypeSHA256
EmailCryptType.EmailCryptTypeNone
parameter | type | description |
---|---|---|
cryptMethod | EmailCryptType | none, or sha256 |
emails | params string[] | list of emails |
示例:
AppsFlyer.setUserEmails(EmailCryptType.EmailCryptTypeSHA256, "[email protected]", "[email protected]");
setPhoneNumber
void setPhoneNumber(string phoneNumber)
Set the user phone number.
parameter | type | description |
---|---|---|
phoneNumber | string |
示例:
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.
parameter | type | description |
---|---|---|
objectName | string | game 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.
parameter | type | description |
---|---|---|
appID | string | |
campaign | string | |
userParams | Dictionary<string, string> | |
gameObject | MonoBehaviour | game 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.
parameter | type | description |
---|---|---|
adRevenueData | AFAdRevenueData | Instance of AFAdRevenueData containing ad revenue information |
additionalParameters | Dictionary<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.
parameter | type | description |
---|---|---|
appID | string | App ID |
campaign | string | campaign |
params | Dictionary<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-
parameter | type | description |
---|---|---|
parameters | Dictionary<string, string> | |
gameObject | MonoBehaviour | game 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.
parameter | type | description |
---|---|---|
partners | params string[] partners | partners 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.
parameter | type | description |
---|---|---|
partners | params string[] partners | partners 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)
允许为合作伙伴的对接目的发送自定义数据。
parameter | type | description |
---|---|---|
partnerID | string | 渠道的ID(通常以“_int”为后缀)。 |
partnerInfo | params 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.
parameter | type | description |
---|---|---|
token | string | Firebase 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.
parameter | type | description |
---|---|---|
imei | string | device'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.
parameter | type | description |
---|---|---|
androidId | string | device'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.
parameter | type | description |
---|---|---|
wait | bool | True 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.
parameter | type | description |
---|---|---|
id | string | 客户的客户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值。
parameter | type | description |
---|---|---|
sourceName | string |
示例:
#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.
parameter | type | description |
---|---|---|
isCollect | bool |
示例:
#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.
parameter | type | description |
---|---|---|
isCollect | bool |
示例:
#if UNITY_ANDROID && !UNITY_EDITOR
AppsFlyer.setCollectIMEI(true);
#endif
setIsUpdate
void setIsUpdate(bool isUpdate)
手动设置应用程序已更新。
parameter | type | description |
---|---|---|
isUpdate | bool | true if app was updated |
示例:
#if UNITY_ANDROID && !UNITY_EDITOR
AppsFlyer.setIsUpdate(true);
#endif
setPreinstallAttribution
void setPreinstallAttribution(string mediaSource, string campaign, string siteId)
指定预安装归因的制造商或媒体渠道名称。
parameter | type | description |
---|---|---|
mediaSource | string | 预安装归因的制造商或媒体渠道名称。 |
campaign | string | 预安装归因的营销活动名称。 |
siteId | string | 预安装归因的网站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.
parameter | type | description |
---|---|---|
details | AFPurchaseDetailsAndroid | Instance of AFPurchaseDetailsAndroid class |
additionalParameters | Dictionary<string, string> | parameters to be sent with the purchase. |
gameObject | MonoBehaviour | Game 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.
parameter | type | description |
---|---|---|
publicKey | string | 从Google Play控制台获得的许可证密钥。 |
signature | string | data.INAPP_DATA_SIGNATURE. |
purchaseData | string | data.INAPP_PURCHASE_DATA |
price | string | Purchase price |
currency | string | 预安装归因的网站ID。 |
additionalParameters | Dictionary<string, string> | parameters to be sent with the purchase. |
gameObject | MonoBehaviour | Game 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.
parameter | type | description |
---|---|---|
isCollect | bool | true 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)
parameter | type | description |
---|---|---|
disable | bool | true 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.
parameter | type | description |
---|---|---|
disable | bool | true 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.
parameter | type | description |
---|---|---|
disable | bool |
示例:
#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.
parameter | type | description |
---|---|---|
pushPayload | Dictionary<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.
parameter | type | description |
---|---|---|
shouldCollectDeviceName | bool |
示例:
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyer.setShouldCollectDeviceName(true);
#endif
setDisableCollectIAd
void setDisableCollectIAd(bool disableCollectIAd)
用于停止ASA归因。
parameter | type | description |
---|---|---|
disableCollectIAd | bool |
示例:
#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.
parameter | type | description |
---|---|---|
useReceiptValidationSandbox | bool | true 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.
parameter | type | description |
---|---|---|
useUninstallSandbox | bool | true 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.
parameter | type | description |
---|---|---|
details | AFSDKPurchaseDetailsIOS | Instance of AFSDKPurchaseDetailsIOS class. |
extraEventValues | Dictionary<string, string> | The additional param, which you want to receive it in the raw reports. |
gameObject | MonoBehaviour | the 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.
parameter | type | description |
---|---|---|
productIdentifier | string | The product identifier. |
price | string | The product price. |
currency | string | The product currency. |
tranactionId | string | The purchase transaction Id. |
additionalParameters | Dictionary<string, string> | The additional param, which you want to receive it in the raw reports. |
gameObject | MonoBehaviour | the 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提供推送设备令牌。
parameter | type | description |
---|---|---|
deviceToken | byte[] | 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.
parameter | type | description |
---|---|---|
url | string | The URL to be passed to your AppDelegate |
sourceApplication | string | The sourceApplication to be passed to your AppDelegate |
annotation | string | The 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.
parameter | type | description |
---|---|---|
timeoutInterval | int | Time to wait for idfa |
示例:
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(60);
#endif
disableSKAdNetwork
bools disableSKAdNetwork(bool isDisabled)
parameter | type | description |
---|---|---|
isDisabled | bool | True to disable SKAdNetwork |
示例:
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyer.disableSKAdNetwork(true);
#endif
setLanguage
setCurrentDeviceLanguage(string language)
parameter | type | description |
---|---|---|
language | String | The language to set |
示例:
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyer.setCurrentDeviceLanguage("english");
#endif
disableIDFVCollection
disableIDFVCollection(bool isDisabled)
parameter | type | description |
---|---|---|
isDisabled | bool | True 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.
parameter | type | description |
---|---|---|
conversionData | string | JSON 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)
parameter | type | description |
---|---|---|
error | string | A 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.
parameter | type | description |
---|---|---|
attributionData | string | JSON 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.
parameter | type | description |
---|---|---|
error | string | string 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.
parameter | type | description |
---|---|---|
link | string | generated link |
示例:
public void onInviteLinkGenerated(string link)
{
}
onInviteLinkGeneratedFailure
public void onInviteLinkGeneratedFailure(string error)
The error callback for generating OneLink URLs
parameter | type | description |
---|---|---|
error | string | A 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
parameter | type | description |
---|---|---|
attributionData | string | JSON 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.
parameter | type | description |
---|---|---|
result | string | validate 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.
parameter | type | description |
---|---|---|
result | string | validate 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.
parameter | type | description |
---|---|---|
error | string | A string describing the error |
示例:
public void onValidateAndLogFailure(string error)
{
AppsFlyer.AFLog("onValidateAndLogFailure", error);
}
事件
onRequestResponse
public static event EventHandler OnRequestResponse
The callback for Sessions.
statusCode | errorDescription |
---|---|
200 | null |
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.
statusCode | errorDescription |
---|---|
200 | null |
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
};
已更新 3 months ago