- SDK Version: 6.1.3 (Release Notes)
- Deprecated SDK versions
重要信息!
Android SDK V6 has major changes from earlier versions to SDK functionality and APIs, including deprecations and method name changes. Learn more about migrating from SDK V5.x.
1. 概述
AppsFlyer Android SDK provides app install and event recording functionality to Android apps. The SDK can be used with Java/Kotlin.
Embed the SDK in your app to record:
- App installs
- User engagement (for example, sessions and in-app events)
1.1 SDK integration—what you need to do
选项卡 | 目的 | After completion |
---|---|---|
SDK集成 ( 强制 ) |
Add and configure the SDK |
|
核心API (推荐) |
Measure in-app events and revenue, Enable deep linking and gather conversion data |
|
Additional APIs |
Implement and use optional APIs. For example, Uninstall measurement and referrals attribution. |
|
SDK APIs reference document |
1.2 SDK与Android平台的兼容性
- Starting Android V4.0
- Non-mobile Android-based platforms such as Smart TVs, including Amazon Fire TV
- Out-of store markets for Android apps, like Amazon, and Baidu
The following sections describe how to implement and initialize the AppsFlyer SDK. After you complete this section, you will see two installs in your AppsFlyer dashboard: organic and non-organic.
2. Add the SDK to your app
2.1 Add the SDK to your project
Use one of the following methods to add the SDK to your app:
- [Best practice] Using Gradle
- Manually add the SDK
- 将以下代码添加到
dependencies
之前的 /app/build.gradle 模块:repositories { mavenCentral() }
- 添加最新版本的AppsFlyer SDK 为dependency。你可以在 此处找到最新版本.
dependencies { //make sure to use the latest SDK version: https://mvnrepository.com/artifact/com.appsflyer/af-android-sdk implementation 'com.appsflyer:af-android-sdk:6.0.0' }
- Sync the project to retrieve the dependencies - see the following screenshot:
2.2 添加Android Install Referrer 到您的App中
Android Install Referrer可提高归因准确性,防止安装欺诈等。从AppsFlyer Android SDK版本4.8.6开始受支持。
注意
Google deprecated the BroadcastReceiver in March 2020.
- 这个改变不会影响到app。
- You may still need the BroadcastReceiver for out-of-store attribution. Check with the store where the app is listed to make sure.
- 现在请务必配置install referrer提高归因准确性。
以下有两种方式可以将Install Referrer 添加到您的App中
- Use Gradle (recommended)
- Manually add the install referrer
把安卓安装Referrer添加为dependency.您可以在 此处找到最新版本.
-
dependencies { //make sure to use the latest SDK version: https://mvnrepository.com/artifact/com.appsflyer/af-android-sdk implementation 'com.appsflyer:af-android-sdk:5.+' implementation 'com.android.installreferrer:installreferrer:1.1' }
- Sync the project to retrieve the dependencies - see the following screenshot:
如果您使用的是ProGuard,并且想使用新的Google referrer API,请设置以下ProGuard规则: -dontwarn com.android.installreferrer
- 下载安装referrer aar
- 将其添加到项目
- 将以下权限添加到manifest中:
com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE
2.3 Set required permissions
添加permissions有助于概率模型归因的比率。它还允许SDK发送更多数据,例如Wifi和运营商网络数据。您可以在原始数据报告找到此数据,并将其用于分析和优化活动。
添加所需权限
- Add the following permissions to
AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- Optional : --> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
2.4 Set BroadcastReceiver to get data from Google Play
注意
Google deprecated the BroadcastReceiver in March 2020.
- 这个改变不会影响到app。
- 您可能仍需要使用BroadcastReceiver进行Google外其他安卓商店的归因。请您与上架应用程序的Google市场外商店进行核对。
- 现在请务必配置install referrer提高归因准确性。
BroadcastReceiver从Google Play获取 AppsFlyer用于归因 。使用BroadcastReceiver可以提高归因率。
实施安装引用广播接收器,有如下两种方案:
If you do not have a receiver listening on the INSTALL_REFERRER
, in AndroidManifest.xml
, in the application
tag add the following receiver:
<application>
<receiver android:name="com.appsflyer.SingleInstallBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
<application>
<receiver android:name="com.appsflyer.MultipleInstallBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>
建议
如果将接收器添加到 AndroidManifest.xml 后出现错误 "Unresolved class SingleInstallBroadcastReceiver", 请确保首先生成应用程序。
3. Implement and initialize the SDK
This section describes how to implement and initialize the SDK.
3.1 Retrieve your dev key
AppsFlyer使用唯一的dev key来标识您的帐户。dev key是强制性的,因为它允许SDK安全地发送和检索属于您AppsFlyer帐户的数据。
Warning! Using the wrong dev key or an incorrect dev key impacts all traffic sent from the SDK and breaks attribution and reporting.
获取您的dev key:
- 转到应用控制面板。
- In the dashboard, under Configuration click App Settings.
- Copy your dev key.
3.2 Initialize the SDK
我们建议在应用程序的全局应用程序类(global application state)中初始化SDK。这使SDK可以在所有方案中进行初始化,包括深度链接。
下述步骤发生在应用的全球应用类(global application class)中。
- 在应用的global class中,导入以下库
import android.app.Application; import android.util.Log; import com.appsflyer.AppsFlyerLib; import com.appsflyer.AppsFlyerConversionListener; import java.util.Map;
- Inside the global class, assign your dev key to a variable, preferably named AF_DEV_KEY.
Important: it is crucial to use the correct dev key when initializing the SDK. Using the wrong dev key or an incorrect dev key impact all traffic sent from the SDK and cause attribution and reporting issues.
public class AFApplication extends Application { private static final String AF_DEV_KEY = "qrdZGj123456789"; //... }
class AFApplication : Application() { private val devKey = "qrdZGj123456789"; //... }
- 在global class内部,在调用
super.onCreate()
后 ,实施AppsFlyerConversionListener
.请参阅下面步骤4中的代码。 - 在global class内部, 在
ConversionListener
后, 利用init()
方法来初始化SDK。
public class AFApplication extends Application { private static final String AF_DEV_KEY = "qrdZGj123456789"; @Override public void onCreate() { super.onCreate(); AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() { @Override public void onConversionDataSuccess(Map<String, Object> conversionData) { for (String attrName : conversionData.keySet()) { Log.d("LOG_TAG", "attribute: " + attrName + " = " + conversionData.get(attrName)); } } @Override public void onConversionDataFail(String errorMessage) { Log.d("LOG_TAG", "error getting conversion data: " + errorMessage); } @Override public void onAppOpenAttribution(Map<String, String> attributionData) { for (String attrName : attributionData.keySet()) { Log.d("LOG_TAG", "attribute: " + attrName + " = " + attributionData.get(attrName)); } } @Override public void onAttributionFailure(String errorMessage) { Log.d("LOG_TAG", "error onAttributionFailure : " + errorMessage); } }; AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, this); } }
class AFApplication : Application() { private val devKey = "qrdZGj123456789"; override fun onCreate() { super.onCreate() val conversionDataListener = object : AppsFlyerConversionListener{ override fun onConversionDataSuccess(data: MutableMap<String, Any>?) { data?.let { cvData -> cvData.map { Log.i(LOG_TAG, "conversion_attribute: ${it.key} = ${it.value}") } } } override fun onConversionDataFail(error: String?) { Log.e(LOG_TAG, "error onAttributionFailure : $error") } override fun onAppOpenAttribution(data: MutableMap<String, String>?) { data?.map { Log.d(LOG_TAG, "onAppOpen_attribute: ${it.key} = ${it.value}") } } override fun onAttributionFailure(error: String?) { Log.e(LOG_TAG, "error onAttributionFailure : $error") } } AppsFlyerLib.getInstance().init(devKey, conversionDataListener, this) } }
- Inside the app's global class, call
start()
.
AppsFlyerLib.getInstance().start(this);
AppsFlyerLib.getInstance().start(this)
3.3注册该global application class
In the AndroidManifest.xml
file, inside the application
tag, add the following line:
android:name="APP.PACKAGE.NAME.AFApplication"
- APP.PACKAGE.NAME - replace this with the app package name.
- AFApplication - replace this with the name that you set for the global app class.
This line in manifest.xml tells the application what is the global applications. As mentioned above, doing so makes the AppsFlyer SDK globally accessible throughout the app.
3.4 Delay SDK initialization
To delay initializing the SDK, you can call start from the Activity class.
This option can be used, if, for example, you need to postpone start until you receive user consent due to GDPR or CCPA requirements, etc.
When invoking start in Activity class:
- 确保将Activity作为argument而不是Application来传递。
- If you plan to use deep linking features, add the
start()
API to any other Activity you can deep link to that doesn’t have start in it.
4. Test installs
You are ready to test the SDK integration by simulating organic and non-organic installs.
4.1 Register your test device
Before you start testing installs, register the test device.
4.2 Simulate an organic install
自然安装是未被归因的安装,通常是直接前往应用商店安装的用户。
要模拟自然安装:
- 确保已将移动设备连接到计算机。
- 在Android Studio中,打开Logcat。
- 在Android Studio中,将应用安装到设备或模拟器上。
- 等待应用启动。
- 在Logcat中,查找该应用的包名。
您应该看到以下内容:
屏幕截图中突出显示的部分表示SDK报告了自然安装。此数据来自AFApplication类中的 onConversionDataSuccess
方法。获取转换数据在 本指南后面将进行讨论 。
注意: 从SDK Version5开始, onConversionDataSuccess
是获取转换数据的方法的名称。如果使用的SDK版本低于5.0.0,则该方法的名称为 onInstallConversionDataLoaded
。我们建议您升级到SDK 5.0.0。要了解更多信息,请点击这里 。
此时该应用的数据总览面板上会出现一个自然安装。
如果您未在应用程序的仪表板上看到安装,请参阅我们的 SDK故障排除指南 。
4.3 Simulate a non-organic install
非自然安装通常是在广告互动之后的可归因安装。您可以使用归因链接模拟非自然安装。
模拟非自然安装:
- 在manifest中,找出您的应用包名,例如com.company.app。
- 在下面的URL中,将<app_id>替换为您的应用包名:
For example:https://app.appsflyer.com/<app_id>?pid=Test&c=Test
https://app.appsflyer.com/id0123456789?pid=Test&c=Test
- c 参数指定广告系列的名称。
- pid 参数指定将安装归因于的媒体渠道的名称。
- Advertising ID (GAID) should be added if testing the click from a computer (by adding
&advertising_id=<GAID>
to the end of the link in step 1).
- 在下面的URL中,将<app_id>替换为您的应用包名:
- 将此URL发送到设备。可以通过电子邮件或WhatsApp发送
- 在设备上,单击URL。
- 如果该应用已在应用商店上架,那您将跳转至应用商店。不要从应用商店下载并安装该应用。继续执行步骤5。
- 如果该应用未在应用商店上架并且仍在开发中,则屏幕会显示‘在应用商店中找不到这个应用’。继续执行步骤5。
- 在Android Studio中,打开Logcat。
- 使用USB数据线将设备连接到计算机。
- 通过Android Studio在设备上安装该应用。
- 在Logcat中,查找该应用的包名。
您应该看到以下内容:
注意
当您已经测试并调试了SDK接入后,请关闭 SDK logs.
集成SDK的已知问题
请参阅以下内容,以了解有关集成SDK时可能出现的问题以及如何解决这些问题的更多信息。
ProGuard警告
如果您使用的是ProGuard,并且遇到有关我们的 AFKeystoreWrapper
类的警告,则将以下代码添加到ProGuard规则文件中:
-keep class com.appsflyer.** { *; }
备份规则
如果您在AndroidManifest.xml的<application>标签内添加 android:fullBackupContent="true"
,您可能会收到错误提示:
Manifest merger failed : Attribute application@fullBackupContent value=(true)
要解决此错误,请在AndroidManifest.xml文件的<application>标签中添加 tools:replace="android:fullBackupContent
。
如果您指定了自己的备份规则(android:fullBackupContent="@xml/my_rules"
),除了上面的说明,请通过添加以下规则将它们与AppsFlyer规则手动合并:
<full-backup-content>
...//your custom rules
<exclude domain="sharedpref" path="appsflyer-data"/>
</full-backup-content>
缺少资源文件
If you are using Android SDK V5 and above, make sure that in the APK file, in addition to the classes.dex and resources files, you also have folder com > appsflyer > internal with files a- and b- inside.
Note: Before SDK 5.3.0, file names are a. and b.
在Android Studio中打开您的APK来检查您是否有必须的文件。请参阅以下屏幕截图以供参考。
如果这些文件丢失,则SDK无法向我们的服务器发出网络请求,您需要联系您的CSM或者Support寻求帮助。
此标签说明了如何记录应用内事件和收入、以及如何设置深度链接。
记录应用内事件和收入可让您衡量用户质量。深度链接可以为用户提供更好的用户体验。
该选项卡是给开发人员的说明,但是市场营销人员的参与也必不可少,原因如下:
- 应当由市场营销人员决定需要记录的应用内事件以衡量用户质量。
- 市场营销人员必须要有访问AppsFlyer控制面板的权限才可以设置OneLink进行深度链接。
5.记录应用内事件
应用内事件可助您深入了解应用里正在发生的事。我们建议您花些时间定义要记录的事件。记录应用内事件有助于您衡量KPI,例如ROI(投资回报率)和LTV(生命周期价值)。
有几种方法可以记录应用内事件。最常见的方法是通过我们在本文中讨论的通过SDK发送事件。要了解其他记录应用内事件的方法,请参见我们的应用内事件概述指南 。
如果您的应用属于某个行业,例如旅行、游戏、电子商务等,您可以参考每个行业的推荐应用内事件列表。
5.1应用内事件名称和参数
SDK具有两个与应用程序内事件相关的接口:
- AFInAppEventType - 应用内事件名称常量。
- AFInAppEventParameterName -应用内事件参数名称常量。
出于以下原因,我们强烈建议使用这两个接口:
- 标准命名使得AppsFlyer可以将事件自动映射到SRN,例如Facebook,Google,Twitter和Snapchat。
- 向后兼容-如果AppsFlyer决定更改任何事件或事件参数的名称,则您的实现是向后兼容的。
要使用这两个接口,请导入它们:
import com.appsflyer.AFInAppEventParameterName;
import com.appsflyer.AFInAppEventType;
这里是推荐事件名称和结构列表 。
5.2记录收入
您可以通过任何应用内事件发送收入。使用 af_revenue
( AFInAppEventParameterName.REVENUE
)事件参数将收入包含在应用内事件中。您可以使用任何数值(正数或负数)填充它。
af_revenue
是AppsFlyer原始数据和控制面板上唯一统计为收入的事件参数。欲了解更多详情请点击这里 。
发送收入事件时,请记住以下几点:
- 如果设置货币代码(请参见下面的示例),则该代码应为 3个字符的ISO 4217代码 。(默认值为美元)。
- 您可以通过调用以下方法为所有事件设置货币代码:
AppsFlyer.setCurrencyCode( " ZZZ " )
要了解有关货币设置、显示和货币换算的信息,请参见我们的收入货币指南。 - 收入值不应包含逗号、货币符号或文本。例如,收入事件应类似于 1234.56。
示例 :有收入的应用内购买事件
Map<String, Object> eventValue = new HashMap<String, Object>();
eventValue.put(AFInAppEventParameterName.REVENUE,1234.56);
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE,"Shirt");
eventValue.put(AFInAppEventParameterName.CONTENT_ID,"1234567");
eventValue.put(AFInAppEventParameterName.CURRENCY,"USD");
AppsFlyerLib.getInstance().logEvent(getApplicationContext() , AFInAppEventType.PURCHASE , eventValue);
val eventValue = HashMap<String, Any>()
eventValue.put(AFInAppEventParameterName.REVENUE,1234.56)
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE,"Shirt")
eventValue.put(AFInAppEventParameterName.CONTENT_ID,"1234567")
eventValue.put(AFInAppEventParameterName.CURRENCY,"USD")
AppsFlyerLib.getInstance().logEvent(getApplicationContext() , AFInAppEventType.PURCHASE , eventValue)
上面的购买事件具有与之相关的收入$ 1234.56,在控制面板上显示为收入。
记录负收入
在某些情况下,您想记录负收入。
例如,用户收到你售出的鞋子的退款。
Map<String, Object> eventValue = new HashMap<String, Object>();
eventValue.put(AFInAppEventParameterName.REVENUE,-200);
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE,"shoes");
eventValue.put(AFInAppEventParameterName.CONTENT_ID,"4875");
eventValue.put(AFInAppEventParameterName.CURRENCY,"USD");
AppsFlyerLib.getInstance().logEvent(getApplicationContext() , "cancel_purchase" , eventValue);
val eventValue = HashMap<String, Any>()
eventValue.put(AFInAppEventParameterName.REVENUE, -200)
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE, "category_a")
eventValue.put(AFInAppEventParameterName.CONTENT_ID, "1234567")
eventValue.put(AFInAppEventParameterName.CURRENCY, "USD")
AppsFlyerLib.getInstance().logEvent(applicationContext, "cancel_purchase", eventValue)
注意
请注意上面代码中的以下内容:
- 收入值前面有一个减号
- 事件名称具有 "cancel_purchase" 的唯一值-允许您在控制面板和原始数据报告中识别负收入事件
5.3应用内购买验证
AppsFlyer’s SDK provides server receipt validation for in-app purchases. To validate a purchase, call the validateAndLogInAppPurchase
.
该方法调用将自动生成一个 af_purchase
应用内事件。
public static void validateAndLogInAppPurchase(Context context,
String publicKey, String signature, String purchaseData,
String price, String currency, HashMap<String, String> additionalParameters);
方法参数
- 字符串publicKey-Google Developer Console的公共密钥。
- 字符串签名–交易签名(购买完成后从Google API返回)。
- 字符串PurchaseData –以JSON格式显示的已购产品(购买完成后从Google API返回)。
- 字符串收入–向AppsFlyer报告应用内事件收入。
- 字符串货币-报告给AppsFlyer的应用内事件货币。
- HashMap<String, String> 额外参数 – 出现在原始数据event_value字段的额外应用内事件参数。
购买验证成功和失败回调
如果您想知道验证购买是否成功,请在application类中实现registerValidatorListener。该监听器有两个回调块,一个用于“成功”,一个用于“失败”(出于任何原因,包括验证失败)。
AppsFlyerLib.getInstance().registerValidatorListener(this,new
AppsFlyerInAppPurchaseValidatorListener() {
public void onValidateInApp() {
Log.d(TAG, "Purchase validated successfully");
}
public void onValidateInAppFailure(String error) {
Log.d(TAG, "onValidateInAppFailure called: " + error);
}
});
AppsFlyerLib.getInstance().registerValidatorListener(this, object : AppsFlyerInAppPurchaseValidatorListener {
override fun onValidateInApp() {
Log.d(LOG_TAG, "Purchase validated successfully")
}
override fun onValidateInAppFailure(error: String) {
Log.d(LOG_TAG, "onValidateInAppFailure called: $error")
}
})
购买验证的用法示例:
// Purchase object is returned by Google API in onPurchasesUpdated() callback
private void handlePurchase(Purchase purchase) {
Log.d(LOG_TAG, "Purchase successful!");
Map<String, String> additional_event_values = new HashMap<>();
additional_event_values.put("some_parameter", "some_value");
String price= "10";
String currency = "USD";
AppsFlyerLib.getInstance().validateAndLogInAppPurchase(getApplicationContext(), PUBLIC_KEY, purchase.getSignature(), purchase.getOriginalJson(), revenue, currency, additional_event_values);
}
// Purchase object is returned by Google API in onPurchasesUpdated() callback
private fun handlePurchase(Purchase purchase) {
Log.d(LOG_TAG, "Purchase successful!");
val additional_event_values = HashMap<String, String>()
additional_event_values.put("some_parameter", "some_value");
val price= "10";
val currency = "USD";
AppsFlyerLib.getInstance().validateAndLogInAppPurchase(this, PUBLIC_KEY, purchase.getSignature(), purchase.getOriginalJson(), revenue, currency, additional_event_values);
}
验证应用内购买会自动将应用内购买事件发送到AppsFlyer。参见下面event_value参数中传递的示例数据:
{
"some_parameter":"some_value", // from additional_event_values
"af_currency":"USD", // from currency
"af_content_id":"test_id", // from purchase
"af_revenue":"10", // from revenue
"af_quantity":"1", // from purchase
"af_validated":true // flag that AF verified the purchase
}
注意
Calling validateAndLogInAppPurchase
automatically generates an af_purchase in-app event. Sending this event yourself creates double duplicate event reporting.
5.4 应用内事件限制
- 事件名称:最多45个字符
- 事件值:不得超过1000个字符-如超过这个长度,我们可能会截断它
- 定价和收入:仅使用数字和小数点,例如5或5.2
- 价格和收入最多可以到小数点后5位,如5.12345
- 从Android SDK V4.8.1开始,应用内事件和其他SDK API都支持非英语字符。
5.5 记录应用内事件的示例
You can record in-app events by calling logEvent
with event name and value parameters. See In-App Events documentation for more details.
以下是有关如何记录购买事件的简单示例。关于每个行业的现成代码片段列表,请参阅详细应用内事件指南
示例:应用内购买活动
Map<String,Object> eventValues = new HashMap<>();
eventValues.put(AFInAppEventParameterName.REVENUE, 1200);
eventValues.put(AFInAppEventParameterName.CURRENCY, "JPY");
eventValues.put(AFInAppEventParameterName.CONTENT_TYPE, "Shoes");
AppsFlyerLib.getInstance().logEvent(this, AFInAppEventType.PURCHASE, eventValues);
val eventValues = HashMap<String, Any>();
eventValues.put(AFInAppEventParameterName.REVENUE, 1200)
eventValues.put(AFInAppEventParameterName.CURRENCY, "JPY")
eventValues.put(AFInAppEventParameterName.CONTENT_TYPE, "Shoes")
AppsFlyerLib.getInstance().logEvent(this, AFInAppEventType.PURCHASE, eventValues)
5.6记录离线应用内事件
如果用户在互联网连接不可用时启动事件,Appsflyer仍然可以记录该事件。它是这样工作的:
- SDK 将事件发送到 AppsFlyer 的服务器并等待响应。
- 如果 SDK 没有收到响应200, 则该事件将存储在缓存中。
- 收到下一个响应200后, 存储的事件将重新发送到服务器。
- 如果缓存中有多个事件, 它们将被立即按序发送到服务器。
注意
SDK 的缓存最多可以存储40个事件, 这意味着只保存脱机发生的前40个事件。所有之后的事件都会被丢弃,直到下一个相应200。
原始数据中显示的事件时间是设备再次联机后事件发送到AppsFlyer的时间。不是事件发生的实际时间。
5.7 记录应用内事件处理成功和失败的信息
您可以在记录应用内事件时设置监听器。监听器可以给两种场景定义逻辑:
- 应用内事件已成功记录。
- 记录应用内事件时发生错误。
AppsFlyerLib.getInstance().logEvent(getApplicationContext(), AFInAppEventType.PURCHASE, eventValue, new AppsFlyerRequestListener() {
@Override
public void onSuccess() {
Log.d(LOG_TAG, "Event sent successfully");
}
@Override
public void onError(int i, @NonNull String s) {
Log.d(LOG_TAG, "Event failed to be sent:\n" +
"Error code: " + i + "\n"
+ "Error description: " + s);
}
});
AppsFlyerLib.getInstance().logEvent(getApplicationContext(), AFInAppEventType.PURCHASE, eventValue, object : AppsFlyerRequestListener {
override fun onSuccess() {
Log.d(LOG_TAG, "Event sent successfully")
}
override fun onError(errorCode: Int, errorDesc: String) {
Log.d(LOG_TAG, "Event failed to be sent:\n" +
"Error code: " + errorCode + "\n"
+ "Error description: " + errorDesc)
}
})
如果在记录应用内事件的时候发生错误,错误代码和字符串说明如下,请参考:
错误代码 | 字符串解释 |
---|---|
10 |
"事件超时,检查'minTimeBetweenSessions'参数" |
11 |
"Skipping event because 'isStopped' enabled" |
40 |
网络错误:错误说明来自Android |
41 |
“没有dev key” |
50 |
"状态代码错误"+实际服务器响应代码 |
6. 用OneLink进行深度链接
OneLink是AppsFlyer的对平台归因、 跳转和深度链接的解决方案。
6.1设备检测和跳转
OneLink在设备点击时检测到设备类型,并将用户跳转到匹配的目的地,例如Google Play商店、iOS应用商店、第三方应用商店、或者网页。
OneLink跳转指南讨论了如何实现多平台归因链接(无需SDK编码)。这也是深层链接的基础。
6.2 深度链接
深度链接使您可以将用户发送到特定活动,并为他们提供自定义内容。该功能在运行再营销广告系列时特别有用。
要运用OneLink进行深度链接, 有权访问AppsFlyer控制面板的市场营销人员和有权访问该应用的开发人员必须共同合作 。
请参阅我们的用于深度链接的URI Scheme设置指南 。
6.3 延迟深度连结
延迟深度链接可以深度链接新用户,并在他们安装应用后为其展示自定义内容。这不同于常规的深度链接,在常规深度链接中,应用必须已经安装在用户设备上。
要用OneLink实现延迟深度链接,开发人员需要有访问AppsFlyer控制面板的权限。
延迟深度链接的设置与深度链接相同。唯一的区别是,您需要在应用中实现其他逻辑,以便在用户安装和启动应用后将他们深度链接到自定义内容。
请参阅深度链接设置指南了解更多信息。
6.4 获取深度链接数据
在每次安装或深度链接发生后,SDK都会为您提供转化或互动数据。您可以使用此数据并配置代码逻辑来触发自定义内容或应用内的特定活动
当深度链接直接打开应用程序时想要获取深度链接数据,请配置onAppOpenAttribution 。
要随时手动获取深度链接的再互动数据,请配置performOnAppAttribution 。这将允许访问re-engagement数据, 而不会算作一个新的re-engagement转化 。
请参阅深度链接设置了解更多信息。
6.5 Configure push notification deep link resolution
The addPushNotificationDeepLinkPath
method provides app owners with a flexible interface for configuring how deep links are extracted from push notification payloads.
By default, the SDK looks for a deep link value in the af
key of a push notification’s JSON
payload. However, many push providers use proprietary JSON
schemas that the SDK can’t resolve without additional configuration.
addPushNotificationDeepLinkPath
enables you to configure which key in the push notification’s payload the SDK uses for the deep link value.
Use this method if you’re integrating your app with push providers that don’t use the default push notification JSON
schema the SDK expects.
When calling addPushNotificationDeepLinkPath
, the SDK verifies that:
- The required key exists in the payload.
- The key contains a valid OneLink URL.
addPushNotificationDeepLinkPath
must be called before calling start()
.
Basic configuration
Consider the following call to addPushNotificationDeepLinkPath
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
and these scenarios.
Scenario 1
Your app is invoked via push notification. It contains a payload structured as follows.
{
...
"deeply": {
"nested": {
"deep_link": "https://yourdeeplink2.onelink.me"
}
}
...
}
In this scenario, the SDK extracts the value of deep_link
and proceeds with the deep linking flow.
Scenario 2
Your app is invoked via push notification. It contains a payload structured as follows.
{
...
"deeply": {
"nested": {
"banana": "https://yourdeeplink2.onelink.me"
}
},
...
}
In this scenario, when the call executes the SDK can't find the deep_link
key in the payload. Therefore, nothing happens.
Scenario 3
Your app is invoked via push notification. It contains a payload structured as follows.
{
...
"deeply": {
"nested": {
"deep_link": "Corrupted url or regular string"
}
},
...
}
In this scenario, although the SDK finds the deep_link
key, its deep link value is invalid. Therefore, when the above call executes, nothing happens.
Advanced configuration
To configure multiple possible payload structures, call addPushNotificationDeepLinkPath
multiple times:
- The first call that yields a valid deep link value is used
- Other calls are ignored
If none of the payload structures match or no valid OneLink URL is found in the payload, nothing happens.
For example, consider the following payload:
{
...
"deeply": {
"nested": {
“deep_link”: “https://yourdeeplink2.onelink.me”
}
},
“this”: {
“is”: {
"banana": "phone"
}
}
...
}
and the following calls to addPushNotificationDeepLinkPath
.
// this.is.deep_link key isn’t found - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "deep_link");
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "banana");
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
// this.is.deep_link key isn’t found - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "deep_link");
// this.is.banana key found, but contains invalid OneLink URL - nothing happens
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("this", "is", "banana");
// deeply.nested.deep_link key found and contains valid OneLink URL - proceed deep linking flow
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
7. 获取转化数据
在SDK层级,您可以实时的获取每一次新安装用户的归因数据
通过这个方式,你可以为用户提供个性化的内容,或者将他们带到App内的指定activity页面 (请查看本篇文章里的 deferred deep linking ).这会大幅提高用户与App的互动程度。
要从Android SDK获取AppsFlyer的转换数据,请执行 AppsFlyerConversionListener
。
import android.app.Application;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerConversionListener;
import java.util.Map;
import android.util.Log;
public class AFApplication extends Application {
private static final String AF_DEV_KEY = "qrdZGj123456789";
@Override
public void onCreate() {
super.onCreate();
AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {
@Override
public void onConversionDataSuccess(Map<String, Object> conversionData) {
for (String attrName : conversionData.keySet()) {
Log.d("LOG_TAG", "attribute: " + attrName + " = " + conversionData.get(attrName));
}
}
@Override
public void onConversionDataFail(String errorMessage) {
Log.d("LOG_TAG", "error getting conversion data: " + errorMessage);
}
@Override
public void onAppOpenAttribution(Map<String, String> conversionData) {
for (String attrName : conversionData.keySet()) {
Log.d("LOG_TAG", "attribute: " + attrName + " = " + conversionData.get(attrName));
}
}
@Override
public void onAttributionFailure(String errorMessage) {
Log.d("LOG_TAG", "error onAttributionFailure : " + errorMessage);
}
};
AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, getApplicationContext());
AppsFlyerLib.getInstance().start(this);
}
}
import com.appsflyer.AppsFlyerConversionListener
import com.appsflyer.AppsFlyerLib
import com.appsflyer.AppsFlyerLibCore.LOG_TAG
class AFApplication : Application() {
private val devKey = "qrdZGj123456789";
override fun onCreate() {
super.onCreate()
val conversionDataListener = object : AppsFlyerConversionListener{
override fun onConversionDataSuccess(data: MutableMap<String, Any>?) {
data?.let { cvData ->
cvData.map {
Log.i(LOG_TAG, "conversion_attribute: ${it.key} = ${it.value}")
}
}
}
override fun onConversionDataFail(error: String?) {
Log.e(LOG_TAG, "error onAttributionFailure : $error")
}
override fun onAppOpenAttribution(data: MutableMap<String, String>?) {
data?.map {
Log.d(LOG_TAG, "onAppOpen_attribute: ${it.key} = ${it.value}")
}
}
override fun onAttributionFailure(error: String?) {
Log.e(LOG_TAG, "error onAttributionFailure : $error")
}
}
AppsFlyerLib.getInstance().init(devKey, conversionDataListener, applicationContext)
AppsFlyerLib.getInstance().start(this)
}
}
AppsFlyerConversionListener
接口中两个最重要的API是:
-
onInstallConversionData
- provides conversion data for new installs.
Note: Starting SDK V5,onConversionDataSuccess
is the name of the method for getting conversion data. If you are using an SDK version lower than 5.0.0, the name of the method isonInstallConversionDataLoaded
. You should upgrade to SDK 5.0.0. To learn more, click here. -
onAppOpenAttribution
在启动现有应用时(手动或通过深度链接)提供再营销的转化数据。
要了解有关转化数据的更多信息,请参见关于转化数据方案指南。
8.归因
第三方应用商店的安卓应用
使用AppsFlyer,您可以归因第三方商店的Android应用安装。这样一来,您就可以在无法使用Google Play的市场中推广应用并触达更大的受众
关于第三方应用商店安装归因的详情,请参阅此处。
预装应用的归因
在预安装广告系列中,应用所有者可以要求设备制造商在设备出厂前预装他们的应用。
使用AppsFlyer可以轻松对预装应用进行归因。用户首次启动您的应用时,AppsFlyer会将安装归因给作为媒体渠道的设备制造商。
如需了解详情,请点击此处。
监测卸载
要了解如何设置卸载监测,请在 此处阅读.
Setting a request listener
If you want to receive a confirmation that the request was successfully received by the AppsFlyer servers, implement the AppsFlyerRequestListener listener.
The onRequestSuccess()
callback method is invoked for every 200 response
to an attribution request made by the SDK.
The onRequestFailure(String error)
callback method is invoked for any other response and returns the response as the error string.
实施实例
AppsFlyerLib.getInstance().start(getApplicationContext(), "devKey", new AppsFlyerRequestListener() {
@Override
public void onSuccess() {
Log.d(LOG_TAG, "Launch sent successfully, got 200 response code from server");
}
@Override
public void onError(int i, @NonNull String s) {
Log.d(LOG_TAG, "Launch failed to be sent:\n" +
"Error code: " + i + "\n"
+ "Error description: " + s);
}
});
AppsFlyerLib.getInstance().start(this, "devKey", object : AppsFlyerRequestListener {
override fun onSuccess() {
Log.d(LOG_TAG, "Launch sent successfully")
}
override fun onError(errorCode: Int, errorDesc: String) {
Log.d(LOG_TAG, "Launch failed to be sent:\n" +
"Error code: " + errorCode + "\n"
+ "Error description: " + errorDesc)
}
})
如果在请求listener的期间事件发生错误,错误代码和字符串说明如下,请参考:
错误代码 | 字符串解释 |
---|---|
10 |
"事件超时,检查'minTimeBetweenSessions'参数" |
11 |
"Skipping event because 'isStopped' enabled" |
40 |
网络错误:错误说明来自Android |
41 |
“没有dev key” |
50 |
"状态代码错误"+实际服务器响应代码 |
设置其他自定义数据
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.
setAdditionalData
代码示例:
HashMap<String,Object> CustomDataMap = new HashMap<>();
CustomDataMap.put("custom_param_1","value_of_param_1");
AppsFlyerLib.getInstance().setAdditionalData(CustomDataMap);
val customDataMap = HashMap<String, Any>()
customDataMap.put("custom_param_1","value_of_param_1")
AppsFlyerLib.getInstance().setAdditionalData(customDataMap)
Attribute app sessions initiated from owned websites (domains)
App owners using App Links for deep linking (without OneLink), and have a domain associated with their app can attribute sessions initiated via this domain using the appendParametersToDeepLinkingURL
method.
For example, a user searches Google and clicks on your domain, www.example.com:
- If the user doesn’t have the app installed, they are directed to the website (www.example.com).
- If the user has the app installed on their device, they are deep linked into the app associated with www.example.com. The session is attributed to the media source (
pid
parameter) specified inappendParametersToDeepLinkingURL
.
See the Android SDK reference for additional information.
Note: Smart Banners help app owners convert website visitors to app users.
9. 会话
自定义会话间的时间
默认情况下,在2次应用启动之间必须至少间隔 5秒,才能将其计为2次独立的应用启动 (更多有关应用启动计数的信息)。
使用以下API设置会话之间的最短时间:
appsflyerlib. setmintimemebetweensession (intseconds);
将两次启动之间的自定义时间设置为高值 可能严重影响依赖会话数据的API (例如深度链接) 。
面向实用应用的后台会话
您可以使用此SDK方法报告新的用户会话。例如,这可能对于在后台运行的工具类应用很方便。
在活动的onCreate()中使用此API:
public void logSession(Context context);
用法示例:
AppsFlyerLib.getInstance().logSession(context);
10.自有媒体
解决已包装的深度链接 URL
某些第三方服务,例如电子邮件服务提供商用他们自己的点击记录域名把链接包在电子邮件中。有些甚至允许您设置自己的点击记录域名。如果OneLink包在此类域名中,则可能会限制其功能。
要解决此问题,您可以使用 setResolveDeepLinkURLs
API。使用此API从启动应用程序的点击域中获取OneLink。请确保在 SDK 初始化之前调用此 API。
例如,您有三个点击域名会跳转到您的OneLink,即https://mysubdomain.onelink.me/abCD。使用此API获取您点击域重定向到的OneLink。此API方法接收SDK解析的域列表。在SDK初始化之前添加以下代码。
AppsFlyerLib.getInstance().setResolveDeepLinkURLs("clickdomain.com", "myclickdomain.com", "anotherclickdomain.com");
上面的代码使您可以在保留OneLink功能的同时使用点击域名。点击域名负责启动应用。该API会从这些点击域名中获取OneLink,然后您可以使用此OneLink中的数据进行深度链接和自定义用户内容。
记录推送通知
借助AppsFlyer,您可以记录作为再营销广告重要部分的推送通知。
要启用此功能,请在点击通知后启动的每个活动的 onCreate
方法内调用 sendPushNotificationData
:
AppsFlyerLib.getInstance().sendPushNotificationData(this);
有关推送通知测量的更多信息,请参阅此处 。
用户邀请归因
允许您的现有用户邀请他们的朋友和联系人作为新用户加入应用,这可能是应用增长的关键因素。使用AppsFlyer,您可以在应用中归因和记录源自用户邀请的安装。
有关详细信息,请参见用户邀请归因文章 。
交叉推广归因
For details, see the Cross Promotion Attribution article, here.
11. 用户标识符
获取AppsFlyer ID
将为每个新增安装创建一个AppsFlyer ID。您可以将AppsFlyer ID用于多种用途:
- 发送服务器到服务器应用内事件 。
- 将AppsFlyer ID与您后台的用户记录进行匹配。
- 合并 pull 和 push API时映射条目。
使用以下API获取AppsFlyer ID:
public String getAppsFlyerUID(Context context);
使用示例:
String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this);
设置客户用户 ID
要设置您的客户用户 ID:
public void setCustomerUserId(String id);
使用示例:
AppsFlyerLib.getInstance().setCustomerUserId("myId");
我们建议在应用流早期设置Customer User ID,因为它仅会关联设置之后上报的事件:
- If
setCustomerUserId
is called before callingstart
, the Customer User ID appears in the raw data reports for installs and for events. - 如果在此之后设置,则“Customer User ID”仅关联该设置之后记录的事件。
获取客户用户 ID
为避免在首次启动后再次设置“Customer User ID”值,并减少向服务器请求Customer User ID的次数,可以使用以下方法检查其值是否为空:
AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID)
了解客户用户 ID 的更多信息,请点击此处。
为 customerUserID 延迟 SDK 初始化
您可以延迟SDK初始化,直到设置了customerUserID。
指示 SDK 应延迟客户用户 ID 调用的初始化
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
紧接 init () 方法之前。SDK 初始化的其他部分保持不变。
有了 customerUserID 之后 , 请调用
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id", this);
为SDK提供相关的客户用户ID并启动SDK。
代码应如下所示:
public class AFApplication extends Application {
private static final String AF_DEV_KEY = "qrdZGj123456789";
@Override
public void onCreate() {
super.onCreate();
AppsFlyerConversionListener conversionDataListener =
new AppsFlyerConversionListener() {
...
};
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
//WARNING! Removing above line doesn't cancel its effect.
// Replace with this to stop waiting for CUID:
// AppsFlyerLib.getInstance().waitForCustomerUserId(false);
AppsFlyerLib.getInstance().init(AF_DEV_KEY, getConversionListener(), getApplicationContext());
AppsFlyerLib.getInstance().start(this);
// Do your magic to get the customerUserID
// ...
// any AppsFlyer SDK code invoked here will be discarded
//Call the following API once the customerUserID is available:
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id", this);
}
}
class AFApplication: Application() {
private val afDevKey = ""
override fun onCreate() {
super.onCreate()
val conversionDataListener = object: AppsFlyerConversionListener {
...
}
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
//WARNING! Removing above line doesn't cancel its effect.
// Replace with this to stop waiting for CUID:
// AppsFlyerLib.getInstance().waitForCustomerUserId(false);
AppsFlyerLib.getInstance().init(afDevKey, conversionDataListener, this)
AppsFlyerLib.getInstance().start(this)
// Do your magic to get the customerUserID
// ...
// any AppsFlyer SDK code invoked here will be discarded
// Call the following API once the customerUserID is available:
AppsFlyerLib.getInstance().setCustomerIdAndLogSession("customer_id", this)
}
}
To learn more about delaying the SDK initialization until the Customer User ID is available, go here.
警告
仅在适合您的业务逻辑的情况下使用此 API。使用此 API 会提高数据差异的几率,并且可能使应用更容易暴露于诈骗中。
Google Advertising ID
从 SDK 4.8.0 版起,AppsFlyer 自动采集 google_advertising_id
。
采集 Google Advertising ID 的要求仅涵盖 SDK 4.7.X 及以下版本。
OAID、IMEI和Android ID
必须收集至少一个唯一标识符以进行归因。可获得以下标识符:GAID、Android ID、IMEI和OAID。
GAID-Google Advertising ID
从包含Google Play服务的应用中自动收集。如果GAID可用,则应用程序不应收集IMEI和Android ID,以避免违反Google Play政策 。
IMEI 和 Android ID
Disabled by default. Can be collected ONLY for apps that do NOT contain Google Play Services.
Note: Starting with Android 10 (API level 29), released in late 2019, access to the IMEI parameter is restricted.
要将这些ID发送到AppsFlyer:
- 在应用上打开,收集设备IMEI和/或Android ID。
- Call the following APIs BEFORE calling the
start
method:
AppsFlyerLib.getInstance().setImeiData("IMEI_HERE"); AppsFlyerLib.getInstance().setAndroidIdData("ANDROID_ID_HERE");
OAID- 打开广告商标识符
选择退出设备ID收集
开发人员可以选择以下方式退出收集IMEI、Android ID和OAID:
AppsFlyerLib.getInstance().setCollectIMEI(false);
AppsFlyerLib.getInstance().setCollectAndroidID(false);
AppsFlyerLib.getInstance().setCollectOaid(false);
12. 用户隐私
退出
In some extreme cases, you might want to shut down all SDK logging due to legal and privacy compliance. This can be achieved with the isStopped API. Once this API is invoked, the SDK stops functioning and no longer communicates with AppsFlyer servers.
AppsFlyerLib.getInstance().isStopped(true, context);
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.
在任何情况下,可调用相同 API 以重新激活 SDK,但会传递 False。
注意事项
Do not call start
if isStopped
is set to true
To start logging again once isStopped
is set to false
, use the following SDK API:
AppsFlyerLib.getInstance().start(getApplicationContext(), AF_DEV_KEY);
警告
Use the stop API only in cases where you want to fully ignore this user from any and all logging. Using this API SEVERELY impacts your attribution, data collection and deep linking mechanism.
匿名用户数据
在 SDK 初始化过程中,使用该 API 明确匿名用户安装、事件和互动:
public void anonymizeUser(boolean isDisabled);
使用示例:
AppsFlyerLib.getInstance().anonymizeUser(true);
Logging can be restarted by calling anonymizeUser
set to false.
警告
Anonymizing users SEVERELY impacts your attribution information.Use this option ONLY for regions which legally prevents you from collecting your users' information.
停止合作伙伴获取数据
在某些情况下,广告主可能希望停止与媒体渠道/合作伙伴共享特定用户的用户级数据。其原因包括:
- 隐私政策,例如CCPA或GDPR
- 用户选择退出机制
- 与某些合作伙伴(媒体渠道,第三方)的竞争
AppsFlyer提供了两种API方法来停止与某些或所有合作伙伴共享数据:
- setSharingFilter: 广告主可以用来设置 一些 (一个或多个)媒体/对接合作伙伴 不能 获得数据。
- setSharingFilterForAllPartners: 广告主可以用来排除 所有 媒体/对接合作伙伴 获得数据。
从SDK V5.4.1开始支持这些过滤方法。
每次SDK初始化 ,都必须调用过滤方法 ,这会影响全部会话。如果需要时间确定是否需要设置sharing filters,请延迟SDK初始化 。
When the method is activated before the first start call:
- 自于SRN平台的用户 会被归因为自然激活用户,并且他们的数据不会回传给合作伙伴。
- 点击广告平台的用户 (非SRN)在AppsFlyer中会被正确归因,但不会通过回调,API,原始数据报告或任何其他方法与广告平台共享数据。
当前,无法使用这些方法过滤卸载数据。但是,您可以在AppsFlyer中的合作伙伴配置页面停止给他们发送卸载事件。
getAppsFlyerUID
描述 |
获取AppsFlyer ID。有关更多信息,请参见此处 。 |
方法签名 |
|
用法示例 |
|
onAppOpenAttribution
描述 |
通过深度链接打开应用时获取深度链接数据。 |
方法签名 |
|
onAttributionFailure
描述 |
处理获取深度链接数据时的报错。 |
方法签名 |
|
onConversionDataSuccess
描述 |
安装后获取转化数据。对于延迟深度链接很有用。 注意: 从SDK Version 第5版开始, |
方法签名 |
|
onConversionDataFail
描述 |
无法获取安装转化数据时处理错误。 |
方法签名 |
|
onDeepLinking
描述 |
Send mobile users with and without your app installed to a specific in-app activity as soon as the app is opened. Learn more |
方法签名 |
|
onRequestFailure
描述 |
Callback method for AppsFlyerRequestListener. Called when the SDK fails to report app launch. |
方法签名 |
|
用法示例 |
onRequestSuccess
描述 |
Callback method for AppsFlyerRequestListener. Called when the SDK successfully reports app launch. |
方法签名 |
|
用法示例 |
performOnAppAttribution
描述 |
此 功能允许开发者们通过指定链接(URI 或者 URL)手动再次触发 onAppOpenAttribution, 而不会记录为一次新的再互动。 此方法适用于当app处于前台或者打开状态时需要基于给定链接或者解析的AppsFlyer short URL去重定向用户的情况。 需要该方法的原因是通常情况下回调 onAppOpenAttribution 只能是通过deep link 打开app的时候。 |
方法签名 |
|
用法示例 |
|
logSession
描述 |
如果您的应用是在后台运行的工具类应用的话,则报告会话。 |
方法签名 |
|
用法示例 |
|
sendDeepLinkData (弃用于 V5.3.0)
描述 |
This method is no longer used to make sure you get attribution data even if the user is deep linked into a specific activity. Instead, ensure that start() has been called. 有关更多信息,请参见这里 。 |
方法签名 |
|
用法示例 |
|
sendPushNotificationData
描述 |
测量并从推送通知活动中获取数据。有关更多信息,请参阅测量推送通知 。 |
方法签名 |
|
用法示例 |
|
setAdditionalData
描述 |
添加要发送到外部合作伙伴平台的其他数据。 |
方法签名 |
|
用法示例 |
参见设置附加数据 。 |
setAndroidIdData
描述 |
将Android ID发给AppsFlyer。参见 OAID、IMEI和Android ID 。 |
方法签名 |
|
用法示例 |
|
setAppInviteOneLink
描述 |
设置用于为用户邀请创建自定义归因链接的OneLink模板ID。 |
方法签名 |
|
用法示例 |
请参阅将 OneLink用于用户邀请归因 。 |
setCollectAndroidID
描述 |
表明是否应将Android ID发给AppsFlyer。 |
方法签名 |
|
用法示例 |
参见 OAID、IMEI和Android ID 。 |
setCollectIMEI
描述 |
表明是否应将IMEI发给AppsFlyer。 |
方法签名 |
|
用法示例 |
参见 OAID、IMEI和Android ID 。 |
setCustomerIdAndLogSession
描述 |
客户用户ID可用后,启动SDK。有关更多信息,请参见为客户用户ID延迟SDK初始化 。 |
方法签名 |
|
用法示例 |
|
设置Customer User ID
描述 |
设置客户用户标识 (Customer User ID)。有关更多信息,请参见设置Customer User ID 。 |
方法签名 |
|
用法示例 |
|
setDebugLog
描述 |
启用调试日志。请参阅Android 调试日志。 |
方法签名 |
|
用法示例 |
|
anonymizeUser
描述 |
匿名化用户的安装、事件和会话。有关更多信息,请参见匿名化用户数据 。 |
方法签名 |
|
用法示例 |
|
setLogLevel
描述 |
设置AppsFlyer SDK日志级别。 |
方法签名 |
|
用法示例 |
|
setMinTimeBetweenSessions
描述 |
设置会话之间的最短时间。有关更多信息,请参阅自定义会话间歇。 |
方法签名 |
|
用法示例 |
|
setOaidData
描述 |
将OAID发给AppsFlyer。参见 OAID、IMEI和Android ID 。 |
方法签名 |
|
用法示例 |
|
setOutOfStore
描述 |
指定下载应用的备用应用商店。 |
方法签名 |
|
用法示例 |
|
setPreinstallAttribution
描述 |
设置SDK在预安装的应用启动时报告预安装。 |
方法签名 |
|
用法示例 |
请参阅用于Android的预装广告系列 。 |
setResolveDeepLinkURLs
描述 |
解决点击域名中的OneLink。有关更多信息,请参见深度链接URL包装解析 。 |
方法签名 |
|
用法示例 |
|
setSharingFilter
描述 |
广告主使用它来设置 一些 (一个或多个)广告平台/合作伙伴来 排除他们获取 数据的权限。了解更多 |
方法签名 |
|
用法示例 |
|
setSharingFilterForAllPartners
描述 |
被广告主用来排除所有 广告平台/合作伙伴 获得数据。了解更多 |
方法签名 |
|
用法示例 |
|
start
描述 |
在应用启动时启动SDK。有关更多信息,请参见初始化SDK 。 |
方法签名 |
|
用法示例 |
|
stop
描述 |
关闭所有SDK功能。有关更多信息,请参阅用户隐私退出 。 |
方法签名 |
|
用法示例 |
|
trackAppLaunch (弃用于 V5.2.0)
描述 |
This method is deprecated. Use start instead. 有两个功能:
|
方法签名 |
|
用法示例 |
|
logEvent
描述 |
将应用内事件发给AppsFlyer。有关更多信息,请参阅记录应用内事件 。 |
方法签名 |
|
用法示例 |
|
updateServerUninstallToken
描述 |
对于将Firebase用于卸载测量以外目的的开发人员。有关更多信息,请参阅卸载测量 。 |
方法签名 |
|
用法示例 |
|
waitForCustomerUserId
描述 |
延迟SDK初始化,直到设置了客户用户ID。 |
方法签名 |
|
用法示例 |
|
appendParametersToDeepLinkingURL
描述 |
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.
|
方法签名 |
|
用法示例 |
|
addPushNotificationDeepLinkPath
描述 |
Configure how the SDK extracts deep link values from push notification payloads. |
方法签名 |
|
用法示例 |
This call matches the following payload structure:
|
已弃用 APIs
A 已弃用 API 意味着该方式 将会被替代。对于广告主来说这是一个很好的 更新代码的时机。
弃用日期 是该方法停止使用或只能以受限的功能继续使用的日期。
API/interface name | 弃用于该版本 | 弃用日期 | Changed to |
---|---|---|---|
trackAppLaunch |
5.2.0 |
2020-10-14 |
|
sendDeepLinkData |
5.3.0 |
2020-10-14 |
|
stopTracking |
6.0.0 |
|
stop |
setCustomerIdAndTrack |
6.0.0 |
|
setCustomerIdAndLogSession |
startTracking |
6.0.0 |
|
start |
trackLocation |
6.0.0 |
|
logLocation |
reportTrackSession |
6.0.0 |
|
logSession |
trackEvent |
6.0.0 |
|
logEvent |
setDeviceTrackingDisabled |
6.0.0 |
|
anonymizeUser |
validateAndTrackInAppPurchase |
6.0.0 |
|
validateAndLogInAppPurchase |
isStopTracking |
6.0.0 |
|
isStopped |
trackAndOpenStore |
6.0.0 |
|
logAndOpenStore |
trackCrossPromoteImpression |
6.0.0 |
|
logCrossPromoteImpression |
trackInvite |
6.0.0 |
|
logInvite |
AppsFlyerTrackingRequestListener |
6.0.0 |
|
AppsFlyerRequestListener |
评论
......
请登录写评论。