lwb
2020-12-29 f0246db5dc85fd8bd389eb754f30fc2293e5e23a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.secondworld.sdk;
 
import com.appsflyer.AppsFlyerConversionListener;
import com.appsflyer.AppsFlyerLib;
import com.secondworld.sdk.utils.LogUtil;
 
import java.util.HashMap;
import java.util.Map;
 
public class AppsFlyerUtil {
 
    private static final String AF_DEV_KEY = "qrdZGj123456789";
 
    public static void init() {
        AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {
            @Override
            public void onConversionDataSuccess(Map<String, Object> conversionData) {
 
                for (String attrName : conversionData.keySet()) {
                    LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName));
                }
            }
 
            @Override
            public void onConversionDataFail(String errorMessage) {
                LogUtil.debug("AppsFlyerMgr", "error getting conversion data: " + errorMessage);
            }
 
            @Override
            public void onAppOpenAttribution(Map<String, String> conversionData) {
 
                for (String attrName : conversionData.keySet()) {
                    LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName));
                }
 
            }
 
            @Override
            public void onAttributionFailure(String errorMessage) {
                LogUtil.debug("AppsFlyerMgr", "error onAttributionFailure : " + errorMessage);
            }
        };
 
        AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, GameApp.I);
        AppsFlyerLib.getInstance().startTracking(GameApp.I);
    }
 
    //统计事件
    public static void trackEvent(String eventName, Map<String, Object> eventValues) {
        if (eventValues == null)
            eventValues = new HashMap<>();
        AppsFlyerLib.getInstance().trackEvent(GameApp.I, eventName, eventValues);
    }
 
}