wangguan
2020-10-22 7a007a8d1e7cd712fa4571efdbc3f2eba7a7e4d0
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using UnityEngine;
using System.Collections.Generic;
 
public class TDGADemoScript : MonoBehaviour
{
    private const int top = 100;
    private const int left = 80;
    private const int height = 50;
    private readonly int width = Screen.width - (left * 2);
    private const int step = 60;
    private string deviceId;
    private string oaid;
    private TDGAAccount account;
    private int index = 1;
    private int level = 1;
 
    private void OnGUI()
    {
        int i = 0;
        GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "Demo Menu");
 
        GUI.Label(new Rect(left, top + (step * i++), width, height), deviceId);
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "getDeviceId"))
        {
            deviceId = TalkingDataGA.GetDeviceId();
        }
 
        GUI.Label(new Rect(left, top + (step * i++), width, height), oaid);
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "getOAID"))//由于IMEI属于隐私,高版本安卓 不支持获取
        {
            oaid = TalkingDataGA.GetOAID();
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "SetLocation"))
        {
            TalkingDataGA.SetLocation(39.94, 116.43);
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Create Account"))
        {
            account = TDGAAccount.SetAccount("User" + index++);
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Account Name"))
        {
            if (account != null)
            {
                account.SetAccountName("name");
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Account Type"))
        {
            if (account != null)
            {
                account.SetAccountType(AccountType.WEIXIN);
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Level"))
        {
            if (account != null)
            {
                account.SetLevel(level++);
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Gender"))
        {
            if (account != null)
            {
                account.SetGender(Gender.MALE);
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Age"))
        {
            if (account != null)
            {
                account.SetAge(21);
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "设置区服"))
        {
            if (account != null)
            {
                account.SetGameServer("server1");
            }
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Begin"))
        {
            TDGAMission.OnBegin("miss001");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Completed"))
        {
            TDGAMission.OnCompleted("miss001");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Failed"))
        {
            TDGAMission.OnFailed("miss001", "failed");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "充值"))
        {
            TDGAVirtualCurrency.OnChargeRequest("order01", "iap", 10, "CNY", 10, "UnionPay");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "充值 Success"))
        {
            TDGAVirtualCurrency.OnChargeSuccess("order01");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "追踪获赠的虚拟币"))
        {
            TDGAVirtualCurrency.OnReward(100, "reason");
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "记录付费点"))
        {
            TDGAItem.OnPurchase("itemid001", 10, 10);
        }
 
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "消耗物品或服务等"))
        {
            TDGAItem.OnUse("itemid001", 1);
        }
 
#if TDGA_CUSTOM
        if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Custome Event"))
        {
            Dictionary<string, object> dic = new Dictionary<string, object>
            {
                { "StringValue", "Pi" },
                { "NumberValue", 3.14 }
            };
            TalkingDataGA.OnEvent("action_id", dic);
        }
#endif
    }
 
    private void Start()
    {
        Debug.Log("Start");
        //TalkingDataGA.SetVerboseLogDisabled();
        TalkingDataGA.BackgroundSessionEnabled();
        TalkingDataGA.OnStart("your_app_id", "your_channel_id");
        account = TDGAAccount.SetAccount("User" + index++);
#if TDGA_PUSH
#if UNITY_IPHONE
        UnityEngine.iOS.NotificationServices.RegisterForNotifications(
            UnityEngine.iOS.NotificationType.Alert |
            UnityEngine.iOS.NotificationType.Badge |
            UnityEngine.iOS.NotificationType.Sound);
#endif
#endif
    }
 
    private void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }
#if TDGA_PUSH
        TalkingDataGA.SetDeviceToken();
        TalkingDataGA.HandlePushMessage();
#endif
    }
 
    private void OnDestroy()
    {
        Debug.Log("onDestroy");
        TalkingDataGA.OnEnd();
    }
 
    private void Awake()
    {
        Debug.Log("Awake");
    }
 
    private void OnEnable()
    {
        Debug.Log("OnEnable");
    }
 
    private void OnDisable()
    {
        Debug.Log("OnDisable");
    }
}