com.amanotes.gdk 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/{Samples~/Example/AmaGDKExample.unity.meta → Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta} +1 -1
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
- package/Runtime/AmaGDK.Adapters.cs +19 -0
- package/Runtime/AmaGDK.Ads.cs +2 -16
- package/Runtime/AmaGDK.RemoteConfig.cs +282 -55
- package/Runtime/AmaGDK.Utils.cs +42 -13
- package/Runtime/AmaGDK.WebUtils.cs +6 -9
- package/Runtime/AmaGDK.cs +5 -4
- package/package.json +1 -1
- package/Packages/AppsflyerAdapter_v6.5.4.unitypackage +0 -0
- package/Runtime/AmaPassport/AmaGDK.AmaPassport.cs +0 -444
- package/Runtime/AmaPassport/AmaGDK.AmaPassport.cs.meta +0 -11
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java +0 -7
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java.meta +0 -32
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs +0 -96
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs.meta +0 -11
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java +0 -79
- package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java.meta +0 -32
- package/Runtime/AmaPassport/Plugins/Android.meta +0 -8
- package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs +0 -59
- package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs.meta +0 -11
- package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm +0 -52
- package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm.meta +0 -33
- package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h +0 -281
- package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h.meta +0 -33
- package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m +0 -1393
- package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m.meta +0 -33
- package/Runtime/AmaPassport/Plugins/iOS.meta +0 -8
- package/Runtime/AmaPassport/Plugins.meta +0 -8
- package/Runtime/AmaPassport.meta +0 -8
- package/Samples~/Example/AmaGDKExample.cs +0 -87
- package/Samples~/Example/AmaGDKExample.cs.meta +0 -11
- package/Samples~/Example/AmaGDKExample.unity +0 -3114
- package/Sample~/Example/AmaGDKExample.cs +0 -87
- package/Sample~/Example/AmaGDKExample.cs.meta +0 -11
- package/Sample~/Example/AmaGDKExample.unity +0 -3114
- package/Sample~/Example/AmaGDKExample.unity.meta +0 -7
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections;
|
|
3
|
-
using System.Collections.Generic;
|
|
4
|
-
using Amanotes.Core.Internal;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
using UnityEngine.Networking;
|
|
7
|
-
using static Amanotes.Core.Internal.Logging;
|
|
8
|
-
|
|
9
|
-
namespace Amanotes.Core.Internal
|
|
10
|
-
{
|
|
11
|
-
[Serializable]
|
|
12
|
-
public class AmaPassportConfig
|
|
13
|
-
{
|
|
14
|
-
public string secretKey;
|
|
15
|
-
public bool enableAmaPassport;
|
|
16
|
-
public bool injectLocation;
|
|
17
|
-
public bool injectAdvertisingId;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public partial class ConfigAsset
|
|
21
|
-
{
|
|
22
|
-
public AmaPassportConfig amaPassport;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
namespace Amanotes.Core
|
|
26
|
-
{
|
|
27
|
-
public partial class AmaGDK //AmaPassport
|
|
28
|
-
{
|
|
29
|
-
public partial class UserProfile
|
|
30
|
-
{
|
|
31
|
-
[SerializeField]
|
|
32
|
-
internal AmaPassportInfo amaPassport = new AmaPassportInfo();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
[Serializable]
|
|
36
|
-
internal class AmaPassportInfo
|
|
37
|
-
{
|
|
38
|
-
[SerializeField] internal DeviceInfo device = new DeviceInfo();
|
|
39
|
-
[SerializeField] internal SocialInfo social = new SocialInfo();
|
|
40
|
-
|
|
41
|
-
public long expireTime;
|
|
42
|
-
public string accessToken = "";
|
|
43
|
-
public string refreshToken = "";
|
|
44
|
-
|
|
45
|
-
internal bool isTokenExpired()
|
|
46
|
-
{
|
|
47
|
-
if (DateTimeOffset.Now.ToUnixTimeMilliseconds() >= expireTime)
|
|
48
|
-
{
|
|
49
|
-
accessToken = "";
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
[Serializable]
|
|
58
|
-
internal class DeviceInfo
|
|
59
|
-
{
|
|
60
|
-
public string amaId = "";
|
|
61
|
-
public string amaDeviceId;
|
|
62
|
-
|
|
63
|
-
public string androidId;
|
|
64
|
-
public string deviceModel;
|
|
65
|
-
public string deviceName;
|
|
66
|
-
public int graphicsDeviceId;
|
|
67
|
-
public int graphicsDeviceVendorId;
|
|
68
|
-
public string operatingSystem;
|
|
69
|
-
public string processorType;
|
|
70
|
-
public int systemMemorySize;
|
|
71
|
-
|
|
72
|
-
public string firebaseUserPseudoId;
|
|
73
|
-
public string appsflyerId;
|
|
74
|
-
public string ironsourceId;
|
|
75
|
-
|
|
76
|
-
public string ipAddress;
|
|
77
|
-
public Location location = new Location();
|
|
78
|
-
public string country;
|
|
79
|
-
public string idfa;
|
|
80
|
-
public string gaid;
|
|
81
|
-
public string idfv;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
[Serializable]
|
|
85
|
-
internal class Location
|
|
86
|
-
{
|
|
87
|
-
public string lat;
|
|
88
|
-
public string lon;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
[Serializable]
|
|
92
|
-
internal class SocialInfo
|
|
93
|
-
{
|
|
94
|
-
public string socialToken;
|
|
95
|
-
public string socialPlatform;
|
|
96
|
-
|
|
97
|
-
internal bool hasLinkSocial
|
|
98
|
-
{
|
|
99
|
-
get { return !string.IsNullOrEmpty(socialPlatform); }
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
[Serializable]
|
|
104
|
-
internal class GeoDataRes
|
|
105
|
-
{
|
|
106
|
-
public string country;
|
|
107
|
-
public string lat;
|
|
108
|
-
public string lon;
|
|
109
|
-
public string query;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public partial class AmaPassport //Token
|
|
113
|
-
{
|
|
114
|
-
private const string API_URL = "https://passport.staging.amanotes.io/api/v3/";
|
|
115
|
-
private const string PASSPORT_URL = API_URL + "passport/";
|
|
116
|
-
private const string TOKEN_URL = API_URL + "token/";
|
|
117
|
-
|
|
118
|
-
private const string GET_AMA_ID_URL = PASSPORT_URL + "get-ama-id";
|
|
119
|
-
private const string SOCIAL_UNLINK_URL = PASSPORT_URL + "logout";
|
|
120
|
-
private const string INIT_URL = TOKEN_URL + "init";
|
|
121
|
-
private const string REFRESH_URL = TOKEN_URL + "refresh-token";
|
|
122
|
-
private const string AMA_DEVICE_ID_KEY = "ama_device_id";
|
|
123
|
-
|
|
124
|
-
[Serializable] class TokenData
|
|
125
|
-
{
|
|
126
|
-
public string expiresIn;
|
|
127
|
-
public string accessToken;
|
|
128
|
-
public string refreshToken;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
[Serializable] class AmaIDData
|
|
132
|
-
{
|
|
133
|
-
public string amaId;
|
|
134
|
-
public string amaDeviceId;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
static IEnumerator RequestTokenRoutine()
|
|
138
|
-
{
|
|
139
|
-
var appSecret = Config.amaPassport.secretKey;
|
|
140
|
-
var passport = User.amaPassport;
|
|
141
|
-
var isRefresh = !string.IsNullOrEmpty(passport.refreshToken);
|
|
142
|
-
|
|
143
|
-
var request = new JsonWebRequest<TokenData>(
|
|
144
|
-
isRefresh ? REFRESH_URL : INIT_URL,
|
|
145
|
-
isRefresh ? JsonUtils.KeyValueToJson("refreshToken", passport.refreshToken)
|
|
146
|
-
: JsonUtils.KeyValueToJson("appSecret", appSecret)
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
yield return _instance.StartCoroutine(request.Send());
|
|
150
|
-
|
|
151
|
-
var data = request.data;
|
|
152
|
-
if (data == null){
|
|
153
|
-
Debug.LogWarning("data should not be null!");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
var expireTime = DateTimeOffset.Now.ToUnixTimeMilliseconds() + int.Parse(data.expiresIn);
|
|
157
|
-
Log("RequestTokenRoutine complete --> accessToken = " + data.accessToken);
|
|
158
|
-
|
|
159
|
-
// Update & save
|
|
160
|
-
passport.accessToken = data.accessToken;
|
|
161
|
-
passport.refreshToken = data.refreshToken;
|
|
162
|
-
passport.expireTime = expireTime;
|
|
163
|
-
User.Save();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
static IEnumerator GetAmaIDRoutine()
|
|
167
|
-
{
|
|
168
|
-
var passport = User.amaPassport;
|
|
169
|
-
if (string.IsNullOrEmpty(passport.accessToken) || passport.isTokenExpired())
|
|
170
|
-
{
|
|
171
|
-
yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
var requestData = new Dictionary<string, object>()
|
|
175
|
-
{
|
|
176
|
-
{"amaId", passport.device.amaId},
|
|
177
|
-
{"social", passport.social},
|
|
178
|
-
{"ids", passport.device}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
var request = new JsonWebRequest<AmaIDData>(
|
|
182
|
-
GET_AMA_ID_URL,
|
|
183
|
-
JsonUtils.DictionaryToJson(requestData),
|
|
184
|
-
passport.accessToken
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
yield return _instance.StartCoroutine(request.Send());
|
|
188
|
-
var data = request.data;
|
|
189
|
-
|
|
190
|
-
Log("GetAmaIDRoutine complete --> amaId = " + data.amaId);
|
|
191
|
-
// Update & Save
|
|
192
|
-
passport.device.amaId = data.amaId;
|
|
193
|
-
OnGetAmaIdComplete?.Invoke(data.amaId);
|
|
194
|
-
User.Save();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
static IEnumerator UnlinkSocialRoutine()
|
|
198
|
-
{
|
|
199
|
-
var amaPassport = User.amaPassport;
|
|
200
|
-
if (string.IsNullOrEmpty(amaPassport.accessToken) || amaPassport.isTokenExpired())
|
|
201
|
-
{
|
|
202
|
-
yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
var social = amaPassport.social;
|
|
206
|
-
social.socialPlatform = string.Empty;
|
|
207
|
-
social.socialToken = string.Empty;
|
|
208
|
-
|
|
209
|
-
var request = new JsonWebRequest<AmaIDData>(
|
|
210
|
-
SOCIAL_UNLINK_URL,
|
|
211
|
-
JsonUtils.KeyValueToJson("ids", amaPassport.device),
|
|
212
|
-
amaPassport.accessToken
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
yield return _instance.StartCoroutine(request.Send());
|
|
216
|
-
var data = request.data;
|
|
217
|
-
|
|
218
|
-
// Update & Save
|
|
219
|
-
Log("[Unlink] amaId: " + data.amaId);
|
|
220
|
-
amaPassport.device.amaId = data.amaId;
|
|
221
|
-
User.Save();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Internal static
|
|
225
|
-
private static void LinkSocialAccount(string platform, string token)
|
|
226
|
-
{
|
|
227
|
-
if (User.amaPassport.social.hasLinkSocial)
|
|
228
|
-
{
|
|
229
|
-
LogWarning("Social has been linked");
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (string.IsNullOrEmpty(AmaId))
|
|
234
|
-
{
|
|
235
|
-
OnGetAmaIdComplete += LinkSocialRequestAmaId;
|
|
236
|
-
void LinkSocialRequestAmaId(string amaId)
|
|
237
|
-
{
|
|
238
|
-
OnGetAmaIdComplete -= LinkSocialRequestAmaId;
|
|
239
|
-
if (string.IsNullOrEmpty(amaId))
|
|
240
|
-
{
|
|
241
|
-
LogWarning("Can not link social");
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
SendLinkSocial(platform, token);
|
|
245
|
-
}
|
|
246
|
-
RequestAmaID();
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
SendLinkSocial(platform, token);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
private static void SendLinkSocial(string platform, string token)
|
|
254
|
-
{
|
|
255
|
-
SocialInfo social = User.amaPassport.social;
|
|
256
|
-
social.socialPlatform = platform;
|
|
257
|
-
social.socialToken = token;
|
|
258
|
-
_instance.StartCoroutine(GetAmaIDRoutine());
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
private static void DoRequestAmaID()
|
|
262
|
-
{
|
|
263
|
-
isInQueue = false;
|
|
264
|
-
_instance.StartCoroutine(GetAmaIDRoutine());
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
public partial class AmaPassport //Support
|
|
269
|
-
{
|
|
270
|
-
|
|
271
|
-
internal static void GetLocation(Action oncomplete)
|
|
272
|
-
{
|
|
273
|
-
_instance.StartCoroutine(GetIP(oncomplete));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
private static IEnumerator GetIP(Action onComplete)
|
|
277
|
-
{
|
|
278
|
-
UnityWebRequest request = UnityWebRequest.Get("http://ip-api.com/json");
|
|
279
|
-
yield return request.SendWebRequest();
|
|
280
|
-
if (string.IsNullOrWhiteSpace(request.error))
|
|
281
|
-
{
|
|
282
|
-
string json = request.downloadHandler.text.Trim();
|
|
283
|
-
var geoData = JsonUtility.FromJson<GeoDataRes>(json);
|
|
284
|
-
if (geoData == null)
|
|
285
|
-
{
|
|
286
|
-
onComplete?.Invoke();
|
|
287
|
-
yield break;
|
|
288
|
-
}
|
|
289
|
-
DeviceInfo device = User.amaPassport.device;
|
|
290
|
-
device.country = geoData.country;
|
|
291
|
-
device.ipAddress = geoData.query;
|
|
292
|
-
device.location = new Location() { lat = geoData.lat, lon = geoData.lon };
|
|
293
|
-
}
|
|
294
|
-
else
|
|
295
|
-
{
|
|
296
|
-
LogWarning("Get location failed: " + request.error);
|
|
297
|
-
}
|
|
298
|
-
Log("Get GeoData completed");
|
|
299
|
-
onComplete?.Invoke();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
public partial class AmaPassport // public APIs
|
|
304
|
-
{
|
|
305
|
-
static ActionQueue actionQueue;
|
|
306
|
-
public static Action<Action> GetAdvertisingIdHook;
|
|
307
|
-
public static Action<Action> GetLocationHook;
|
|
308
|
-
public static Action<Action> ATTHook;
|
|
309
|
-
public static Action<string> OnGetAmaIdComplete;
|
|
310
|
-
private static bool isInQueue = false;
|
|
311
|
-
|
|
312
|
-
public static string AmaId
|
|
313
|
-
{
|
|
314
|
-
get { return User.amaPassport.device.amaId; }
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
public static void LinkWithFacebook(string accessToken)
|
|
318
|
-
{
|
|
319
|
-
LinkSocialAccount("facebook", accessToken);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
public static void LinkWithGoogle(string idToken)
|
|
323
|
-
{
|
|
324
|
-
LinkSocialAccount("google", idToken);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
public static void LinkWithApple(string identityToken)
|
|
328
|
-
{
|
|
329
|
-
LinkSocialAccount("apple", identityToken);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
public static void UnlinkSocialAccount()
|
|
333
|
-
{
|
|
334
|
-
if (!User.amaPassport.social.hasLinkSocial)
|
|
335
|
-
{
|
|
336
|
-
LogWarning("Social has not linked");
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (string.IsNullOrEmpty(AmaId))
|
|
341
|
-
{
|
|
342
|
-
LogWarning("No available AmaId to unlink");
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
_instance.StartCoroutine(UnlinkSocialRoutine());
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
public static void RequestAmaID()
|
|
350
|
-
{
|
|
351
|
-
var config = Config.amaPassport;
|
|
352
|
-
var device = User.amaPassport.device;
|
|
353
|
-
|
|
354
|
-
if (string.IsNullOrEmpty(config.secretKey))
|
|
355
|
-
{
|
|
356
|
-
LogWarning($"Invalid secretKey: {config.secretKey}");
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (!config.enableAmaPassport)
|
|
361
|
-
{
|
|
362
|
-
LogWarning("AmaPassport is disabled!");
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (!string.IsNullOrEmpty(device.amaId))
|
|
367
|
-
{
|
|
368
|
-
Log($"AmaId is already exist: {device.amaId}");
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
GetDeviceInfo(DoRequestAmaID);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
public static void DeletKeyChain()
|
|
376
|
-
{
|
|
377
|
-
KeyChain.DeleteKeyChain(AMA_DEVICE_ID_KEY);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
static void GetDeviceInfo(Action getDeviceInfoComplete)
|
|
381
|
-
{
|
|
382
|
-
if (isInQueue)
|
|
383
|
-
{
|
|
384
|
-
LogWarning("Request AmaId under process");
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
isInQueue = true;
|
|
388
|
-
|
|
389
|
-
var device = User.amaPassport.device;
|
|
390
|
-
device.androidId = SystemInfo.deviceUniqueIdentifier;
|
|
391
|
-
device.deviceModel = SystemInfo.deviceModel;
|
|
392
|
-
device.deviceName = SystemInfo.deviceName;
|
|
393
|
-
device.processorType = SystemInfo.processorType;
|
|
394
|
-
device.systemMemorySize = SystemInfo.systemMemorySize;
|
|
395
|
-
device.graphicsDeviceId = SystemInfo.graphicsDeviceID;
|
|
396
|
-
device.graphicsDeviceVendorId = SystemInfo.graphicsDeviceVendorID;
|
|
397
|
-
device.operatingSystem = SystemInfo.operatingSystem;
|
|
398
|
-
|
|
399
|
-
switch (Application.platform)
|
|
400
|
-
{
|
|
401
|
-
case RuntimePlatform.IPhonePlayer:
|
|
402
|
-
device.idfv = SystemInfo.deviceUniqueIdentifier;
|
|
403
|
-
string v = KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY);
|
|
404
|
-
Debug.Log("AmaDeviceId 111: " + v);
|
|
405
|
-
if (string.IsNullOrEmpty(v))
|
|
406
|
-
{
|
|
407
|
-
device.amaDeviceId = Guid.NewGuid().ToString();
|
|
408
|
-
try
|
|
409
|
-
{
|
|
410
|
-
KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, device.amaDeviceId);
|
|
411
|
-
}
|
|
412
|
-
catch(Exception ex)
|
|
413
|
-
{
|
|
414
|
-
Debug.Log("AmaDeviceId Ex: " + ex);
|
|
415
|
-
}
|
|
416
|
-
Debug.Log("AmaDeviceId 222: " + device.amaDeviceId + ", " + KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY));
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
else
|
|
420
|
-
{
|
|
421
|
-
device.amaDeviceId = v;
|
|
422
|
-
}
|
|
423
|
-
break;
|
|
424
|
-
case RuntimePlatform.Android:
|
|
425
|
-
default:
|
|
426
|
-
device.androidId = SystemInfo.deviceUniqueIdentifier;
|
|
427
|
-
if (string.IsNullOrEmpty(device.amaDeviceId))
|
|
428
|
-
{
|
|
429
|
-
device.amaDeviceId = Guid.NewGuid().ToString();
|
|
430
|
-
}
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
var config = Config.amaPassport;
|
|
435
|
-
actionQueue = new ActionQueue(getDeviceInfoComplete);
|
|
436
|
-
|
|
437
|
-
actionQueue.EnqueueAction(ATTHook);
|
|
438
|
-
if (config.injectLocation) actionQueue.EnqueueAction(GetLocationHook ?? GetLocation);
|
|
439
|
-
if (config.injectAdvertisingId) actionQueue.EnqueueAction(GetAdvertisingIdHook ?? GetAdvertisingId);
|
|
440
|
-
actionQueue.StartQueue();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: b20a41b7f3c814bbd905559d73f7d253
|
|
3
|
-
PluginImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
iconMap: {}
|
|
7
|
-
executionOrder: {}
|
|
8
|
-
defineConstraints: []
|
|
9
|
-
isPreloaded: 0
|
|
10
|
-
isOverridable: 0
|
|
11
|
-
isExplicitlyReferenced: 0
|
|
12
|
-
validateReferences: 1
|
|
13
|
-
platformData:
|
|
14
|
-
- first:
|
|
15
|
-
Android: Android
|
|
16
|
-
second:
|
|
17
|
-
enabled: 1
|
|
18
|
-
settings: {}
|
|
19
|
-
- first:
|
|
20
|
-
Any:
|
|
21
|
-
second:
|
|
22
|
-
enabled: 0
|
|
23
|
-
settings: {}
|
|
24
|
-
- first:
|
|
25
|
-
Editor: Editor
|
|
26
|
-
second:
|
|
27
|
-
enabled: 0
|
|
28
|
-
settings:
|
|
29
|
-
DefaultValueInitialized: true
|
|
30
|
-
userData:
|
|
31
|
-
assetBundleName:
|
|
32
|
-
assetBundleVariant:
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using UnityEngine;
|
|
3
|
-
using static Amanotes.Core.Internal.Logging;
|
|
4
|
-
|
|
5
|
-
namespace Amanotes.Core
|
|
6
|
-
{
|
|
7
|
-
public partial class AmaGDK //AmaPassport
|
|
8
|
-
{
|
|
9
|
-
public partial class AmaPassport //AdvertisingId
|
|
10
|
-
{
|
|
11
|
-
internal static void GetAdvertisingId(Action oncomplete)
|
|
12
|
-
{
|
|
13
|
-
AdvertisingIdFetcher.RequestAdvertisingId(advertisingId =>
|
|
14
|
-
{
|
|
15
|
-
var device = User.amaPassport.device;
|
|
16
|
-
switch (Application.platform)
|
|
17
|
-
{
|
|
18
|
-
case RuntimePlatform.IPhonePlayer:
|
|
19
|
-
device.idfa = advertisingId;
|
|
20
|
-
device.idfv = SystemInfo.deviceUniqueIdentifier;
|
|
21
|
-
var v = KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY);
|
|
22
|
-
if (string.IsNullOrEmpty(v))
|
|
23
|
-
{
|
|
24
|
-
v = Guid.NewGuid().ToString();
|
|
25
|
-
KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, v);
|
|
26
|
-
}
|
|
27
|
-
device.amaDeviceId = v;
|
|
28
|
-
break;
|
|
29
|
-
|
|
30
|
-
case RuntimePlatform.Android:
|
|
31
|
-
device.gaid = advertisingId;
|
|
32
|
-
device.androidId = SystemInfo.deviceUniqueIdentifier;
|
|
33
|
-
break;
|
|
34
|
-
|
|
35
|
-
default:
|
|
36
|
-
LogWarning("Unsupported platform: " + Application.platform);
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
oncomplete?.Invoke();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private class AdvertisingIdFetcher
|
|
46
|
-
{
|
|
47
|
-
public static void RequestAdvertisingId(Action<string> callback)
|
|
48
|
-
{
|
|
49
|
-
new AdvertisingIdFetcher().DoRequestAdvertisingId(callback);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private Action<string> mCallback;
|
|
53
|
-
|
|
54
|
-
private void DoRequestAdvertisingId(Action<string> callback)
|
|
55
|
-
{
|
|
56
|
-
mCallback = callback;
|
|
57
|
-
|
|
58
|
-
#if UNITY_EDITOR
|
|
59
|
-
OnAdvertisingIdReceived("0000-0000-0000-0000");
|
|
60
|
-
#elif UNITY_ANDROID && UNITY_2020_1_OR_NEWER
|
|
61
|
-
var fetcher = new AndroidJavaObject("com.miniit.android.AdvertisingIdFetcher");
|
|
62
|
-
fetcher.Call("requestAdvertisingId", new AdvertisingIdPluginCallback(OnAdvertisingIdReceived));
|
|
63
|
-
#else
|
|
64
|
-
Application.RequestAdvertisingIdentifierAsync(OnAdvertisingIdReceived);
|
|
65
|
-
#endif
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private void OnAdvertisingIdReceived(string advertisingId)
|
|
69
|
-
{
|
|
70
|
-
mCallback?.Invoke(advertisingId);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private void OnAdvertisingIdReceived(string advertisingId, bool trackingEnabled, string errorMsg)
|
|
74
|
-
{
|
|
75
|
-
mCallback?.Invoke(advertisingId);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
#if UNITY_ANDROID && UNITY_2020_1_OR_NEWER
|
|
80
|
-
public class AdvertisingIdPluginCallback : AndroidJavaProxy
|
|
81
|
-
{
|
|
82
|
-
private Action<string> mCallback;
|
|
83
|
-
|
|
84
|
-
public AdvertisingIdPluginCallback(Action<string> callback) : base("com.miniit.android.AdvertisingIdCallback")
|
|
85
|
-
{
|
|
86
|
-
mCallback = callback;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public void onResult(string adid)
|
|
90
|
-
{
|
|
91
|
-
mCallback?.Invoke(adid);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
#endif
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
package com.miniit.android;
|
|
3
|
-
|
|
4
|
-
import com.unity3d.player.UnityPlayer;
|
|
5
|
-
|
|
6
|
-
import android.content.Context;
|
|
7
|
-
import android.os.AsyncTask;
|
|
8
|
-
//import androidx.ads.identifier.AdvertisingIdClient;
|
|
9
|
-
//import androidx.ads.identifier.AdvertisingIdInfo;
|
|
10
|
-
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
|
11
|
-
import java.lang.Exception;
|
|
12
|
-
|
|
13
|
-
public class AdvertisingIdFetcher
|
|
14
|
-
{
|
|
15
|
-
private AdvertisingIdCallback callback;
|
|
16
|
-
|
|
17
|
-
public void requestAdvertisingId(AdvertisingIdCallback callback)
|
|
18
|
-
{
|
|
19
|
-
if (callback == null)
|
|
20
|
-
return;
|
|
21
|
-
|
|
22
|
-
Context context = UnityPlayer.currentActivity.getApplicationContext();
|
|
23
|
-
|
|
24
|
-
// if (!AdvertisingIdClient.isAdvertisingIdProviderAvailable(context))
|
|
25
|
-
// {
|
|
26
|
-
// callback.onResult("");
|
|
27
|
-
// return;
|
|
28
|
-
// }
|
|
29
|
-
|
|
30
|
-
this.callback = callback;
|
|
31
|
-
|
|
32
|
-
new GetAdIdTask(context).execute();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private class GetAdIdTask extends AsyncTask<String, Integer, String>
|
|
36
|
-
{
|
|
37
|
-
private Context context;
|
|
38
|
-
|
|
39
|
-
public GetAdIdTask(Context context)
|
|
40
|
-
{
|
|
41
|
-
super();
|
|
42
|
-
this.context = context;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Override
|
|
46
|
-
protected String doInBackground(String... strings)
|
|
47
|
-
{
|
|
48
|
-
// if (!AdvertisingIdClient.isAdvertisingIdProviderAvailable(context))
|
|
49
|
-
// return "";
|
|
50
|
-
|
|
51
|
-
AdvertisingIdClient.Info adInfo;
|
|
52
|
-
adInfo = null;
|
|
53
|
-
try
|
|
54
|
-
{
|
|
55
|
-
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context);
|
|
56
|
-
if (adInfo.isLimitAdTrackingEnabled()) // check if user has opted out of tracking
|
|
57
|
-
{
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (Exception e)
|
|
62
|
-
{
|
|
63
|
-
e.printStackTrace();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (adInfo != null)
|
|
67
|
-
return adInfo.getId();
|
|
68
|
-
|
|
69
|
-
return "";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@Override
|
|
73
|
-
protected void onPostExecute(String adid)
|
|
74
|
-
{
|
|
75
|
-
if (callback != null)
|
|
76
|
-
callback.onResult(adid);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|