unity sdkandroid-AppsFlyer 平台接入

尽量观看英文版本,AppsFlyer有点坑中文版有的内容不显示

官方文档:

https://support.appsflyer.com/hc/en-us/categories/201114756-SDK-integration-

https://support.appsflyer.com/hc/en-us/articles/360007314277-Unity-plugin-V6-integration-guide-for-developers#integration

主要内容看官方文档,

demo以及unitysdk下载GitHub - AppsFlyerSDK/appsflyer-unity-plugin: AppsFlyer Unity Plugin

导入sdk:appsflyer-unity-plugin-6.1.0.unitypackage ,将AppsFlyerObject.prefab 拖入场景

填入devKey (运营人员申请的)appID(包名)即可

具体API使用:https://support.appsflyer.com/hc/en-us/articles/360007314277-Unity-plugin-V6-integration-guide-for-developers#api-reference-sendevent

打点API:

            Dictionary<string, string> 
            eventValues = new Dictionary<string, string>();
            eventValues.Add("number", "1");
            AppsFlyer.sendEvent("ad_show", eventValues);

有关onConversionDataSuccess的信息,回掉信息解析,

using AppsFlyerSDK;

public class AppsFlyerObjectScript : MonoBehaviour , IAppsFlyerConversionData
{
    void Start()
    {
        /* AppsFlyer.setDebugLog(true); */
        AppsFlyer.initSDK("devkey", "appID", this);
        AppsFlyer.startSDK();
    }

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

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

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

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

使用AppsFlyer  SDK获取数据转换

Dictionary<string, object> conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);

对应数据解析:https://support.appsflyer.com/hc/en-us/articles/360000726098-Get-conversion-data-using-AppsFlyer-SDK#payload-structure

Get AppsFlyer ID 

string AppsFlyerUID = AppsFlyer.getAppsFlyerId();

Set customer user ID(设置用户/账户 id  )与其他统计平台对应(唯一id)

AppsFlyer.setCustomerUserId("someId");

如无服务器则需自己生成唯一id(Android studio写)

    public String GetID(){
        String serial = null;
        String m_szDevIDShort = "35" +
                Build.BOARD.length()%10+ Build.BRAND.length()%10 +

                Build.CPU_ABI.length()%10 + Build.DEVICE.length()%10 +

                Build.DISPLAY.length()%10 + Build.HOST.length()%10 +

                Build.ID.length()%10 + Build.MANUFACTURER.length()%10 +

                Build.MODEL.length()%10 + Build.PRODUCT.length()%10 +

                Build.TAGS.length()%10 + Build.TYPE.length()%10 +

                Build.USER.length()%10 ; //13 位
        try {
            serial = Build.class.getField("SERIAL").get(null).toString();
            //API>=9 使用serial号
            return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
        } catch (Exception exception) {
            //serial需要一个初始化
            serial = "serial"; // 随便一个初始化
        }
        return  new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
        //使用硬件信息拼凑出来的15位号码
    }

注意内容:

问题1、提示AppsFlyer_Unity_v6.0.7 提示 didReceiveConversionDataWithError called with Error connection to server: 400

找运营操作,可能是id未加入测试

问题2、OAID自动获取,unitysdk里面没有具体描述只写了自动获取,但没有加入以下模块无法获取出来

https://support.appsflyer.com/hc/en-us/articles/360006278797-Android-OAID-implementation-in-the-SDK

根据SDK版本选择一种收集方法。Ť他必须开发一个DD制造商的独立JAR文件,应用程序或将其添加到AppsFlyer OAID SDK。 

  1.  将MSA联盟提供 的oaid_sdk_1.0.23.aar下载  到您的模块libs文件夹中(https://github.com/AppsFlyerSDK/appsflyer-oaid/blob/master/oaid/libs/oaid_sdk_1.0.23.aar
  2. 添加OAID依赖关系;他们必须在应用程序级别的build.gradle文件中支持制造商的独立JAR文件:
    • implementation 'com.appsflyer:af-android-sdk:5.4.3@aar'//已包含:af-android-sdk就不用
    • implementation 'com.appsflyer:oaid:6.1.1'
    • implementation files('libs/oaid_sdk_1.0.23.aar')

要在AppsFlyer SDK版本V5.4.0中收集OAID,请执行以下操作:

默认情况下会自动收集OAID。

要在AppsFlyer SDK版本V5.2.0和V5.3.0中收集OAID,请执行以下操作:

先致电setCollectOaid()再致电startTracking()

在代码中,调用 AppsFlyerLib.getInstance().setCollectOaid(true);

问题3、AF的混淆代码

在(AS里的)proguard-unity.txt中加入

#appsflyer
-dontwarn com.appsflyer.**
-keep class com.appsflyer.** { *; }

相关文章

学习编程是顺着互联网的发展潮流,是一件好事。新手如何学习...
IT行业是什么工作做什么?IT行业的工作有:产品策划类、页面...
女生学Java好就业吗?女生适合学Java编程吗?目前有不少女生...
Can’t connect to local MySQL server through socket \'/v...
oracle基本命令 一、登录操作 1.管理员登录 # 管理员登录 ...
一、背景 因为项目中需要通北京网络,所以需要连vpn,但是服...