com.amanotes.gdk 0.2.5 → 0.2.6
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 +6 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/{Packages/AmaPassport.AdvertisingID.unitypackage.meta → Extra/AmaGDKInstaller.unitypackage.meta} +1 -1
- package/Extra.meta +8 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AmaPassport.ATTSupport.unitypackage +0 -0
- package/Packages/AmaPassportAdapter_v1.0.0.unitypackage +0 -0
- package/Packages/AmaPassportAdapter_v1.0.0.unitypackage.meta +7 -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/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +17 -5
- package/Runtime/AmaGDK.AmaPassport.cs +104 -108
- package/Runtime/AmaGDK.Internal.cs +1 -1
- package/Runtime/AmaGDK.RemoteConfig.cs +21 -52
- package/Runtime/AmaGDK.cs +3 -2
- package/package.json +1 -1
- package/Packages/AmaPassport.AdvertisingID.unitypackage +0 -0
package/CHANGELOG.md
CHANGED
|
Binary file
|
package/Extra.meta
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -187,8 +187,6 @@ namespace Amanotes.Core
|
|
|
187
187
|
_adapter.interstitial.StopShowAd();
|
|
188
188
|
else
|
|
189
189
|
_adapter.rewardVideo.StopShowAd();
|
|
190
|
-
|
|
191
|
-
context = null;
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
192
|
}
|
|
@@ -519,38 +517,41 @@ namespace Amanotes.Core.Internal
|
|
|
519
517
|
{
|
|
520
518
|
Ads.context.adCallback |= AdCallback.Click;
|
|
521
519
|
Ads.context.onClicked?.Invoke();
|
|
520
|
+
|
|
522
521
|
if (isInterstitial)
|
|
523
522
|
Ads.Events.OnInterstitialClicked?.Invoke();
|
|
524
523
|
else
|
|
525
524
|
Ads.Events.OnRewardedClicked?.Invoke();
|
|
525
|
+
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
protected void OnAdShowFailed()
|
|
529
529
|
{
|
|
530
530
|
Ads.context.adCallback |= AdCallback.Fail;
|
|
531
531
|
Ads.context.onShowFailed?.Invoke();
|
|
532
|
+
|
|
532
533
|
if (isInterstitial)
|
|
533
534
|
Ads.Events.OnInterstitialShowFailed?.Invoke();
|
|
534
535
|
else
|
|
535
536
|
Ads.Events.OnRewardedShowFailed?.Invoke();
|
|
536
537
|
|
|
537
|
-
Ads.context = null;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
protected void OnAdShowSucceeded()
|
|
541
541
|
{
|
|
542
542
|
Ads.context.adCallback |= AdCallback.Success;
|
|
543
543
|
Ads.context.onShowSuccess?.Invoke();
|
|
544
|
+
|
|
544
545
|
if (isInterstitial)
|
|
545
546
|
Ads.Events.OnInterstitialShowSucceeded?.Invoke();
|
|
546
547
|
|
|
547
|
-
Ads.context = null;
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
protected void OnAdOpen()
|
|
551
551
|
{
|
|
552
552
|
Ads.context.adCallback |= AdCallback.Open;
|
|
553
553
|
Ads.context.onOpened?.Invoke();
|
|
554
|
+
|
|
554
555
|
if (isInterstitial)
|
|
555
556
|
Ads.Events.OnInterstitialOpened?.Invoke();
|
|
556
557
|
else
|
|
@@ -561,11 +562,12 @@ namespace Amanotes.Core.Internal
|
|
|
561
562
|
{
|
|
562
563
|
Ads.context.adCallback |= AdCallback.Reward;
|
|
563
564
|
Ads.context.onRewardReceived?.Invoke();
|
|
565
|
+
|
|
564
566
|
if (!isInterstitial)
|
|
565
567
|
Ads.Events.OnRewardedReceived?.Invoke();
|
|
566
568
|
}
|
|
567
569
|
|
|
568
|
-
protected void
|
|
570
|
+
protected void OnAdLoadSuccess()
|
|
569
571
|
{
|
|
570
572
|
if (!_isRequesting)
|
|
571
573
|
{
|
|
@@ -573,6 +575,14 @@ namespace Amanotes.Core.Internal
|
|
|
573
575
|
}
|
|
574
576
|
|
|
575
577
|
_isRequesting = false;
|
|
578
|
+
if (isInterstitial)
|
|
579
|
+
Ads.Events.OnInterstitialLoadSucceeded?.Invoke();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
protected void OnAdLoadFailed(string error)
|
|
583
|
+
{
|
|
584
|
+
if (isInterstitial)
|
|
585
|
+
Ads.Events.OnInterstitialLoadFailed?.Invoke(error);
|
|
576
586
|
}
|
|
577
587
|
}
|
|
578
588
|
|
|
@@ -589,5 +599,7 @@ namespace Amanotes.Core.Internal
|
|
|
589
599
|
public Action OnInterstitialShowFailed;
|
|
590
600
|
public Action OnInterstitialClicked;
|
|
591
601
|
public Action OnInterstitialClosed;
|
|
602
|
+
public Action OnInterstitialLoadSucceeded;
|
|
603
|
+
public Action<string> OnInterstitialLoadFailed;
|
|
592
604
|
}
|
|
593
605
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
using Amanotes.Core.Internal;
|
|
1
2
|
using System;
|
|
2
3
|
using System.Collections;
|
|
3
4
|
using System.Collections.Generic;
|
|
4
|
-
using Amanotes.Core.Internal;
|
|
5
5
|
using UnityEngine;
|
|
6
6
|
using UnityEngine.Networking;
|
|
7
7
|
using static Amanotes.Core.Internal.Logging;
|
|
8
8
|
|
|
9
9
|
namespace Amanotes.Core.Internal
|
|
10
10
|
{
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
public interface IAmaPassportAdapter
|
|
12
|
+
{ }
|
|
13
|
+
|
|
14
|
+
[Serializable] public class AmaPassportAdapterConfig
|
|
13
15
|
{
|
|
14
16
|
public string secretKey;
|
|
15
17
|
public bool enableAmaPassport;
|
|
@@ -17,29 +19,24 @@ namespace Amanotes.Core.Internal
|
|
|
17
19
|
public bool injectAdvertisingId;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
public partial class ConfigAsset
|
|
21
|
-
{
|
|
22
|
-
public AmaPassportConfig amaPassport;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
22
|
public class AmaPassportSupport
|
|
26
23
|
{
|
|
27
24
|
public static void SetAdvertisingID(string id)
|
|
28
25
|
{
|
|
29
|
-
|
|
26
|
+
AmaGDK.DeviceInfo device = AmaGDK.User.amaPassport.device;
|
|
30
27
|
switch (Application.platform)
|
|
31
28
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
case RuntimePlatform.IPhonePlayer:
|
|
30
|
+
device.idfa = id;
|
|
31
|
+
break;
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
case RuntimePlatform.Android:
|
|
34
|
+
device.gaid = id;
|
|
35
|
+
break;
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
default:
|
|
38
|
+
LogWarning("Unsupported platform: " + Application.platform);
|
|
39
|
+
break;
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -51,8 +48,8 @@ namespace Amanotes.Core.Internal
|
|
|
51
48
|
}
|
|
52
49
|
namespace Amanotes.Core
|
|
53
50
|
{
|
|
54
|
-
public partial class AmaGDK //
|
|
55
|
-
{
|
|
51
|
+
public partial class AmaGDK // UserProfile
|
|
52
|
+
{
|
|
56
53
|
public partial class UserProfile
|
|
57
54
|
{
|
|
58
55
|
[SerializeField]
|
|
@@ -71,16 +68,16 @@ namespace Amanotes.Core
|
|
|
71
68
|
|
|
72
69
|
internal bool isTokenExpired()
|
|
73
70
|
{
|
|
74
|
-
if (DateTimeOffset.Now.ToUnixTimeMilliseconds()
|
|
71
|
+
if (DateTimeOffset.Now.ToUnixTimeMilliseconds() < expireTime)
|
|
75
72
|
{
|
|
76
|
-
|
|
77
|
-
return true;
|
|
73
|
+
return false;
|
|
78
74
|
}
|
|
79
|
-
|
|
75
|
+
|
|
76
|
+
accessToken = "";
|
|
77
|
+
return true;
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
|
|
84
81
|
[Serializable]
|
|
85
82
|
internal class DeviceInfo
|
|
86
83
|
{
|
|
@@ -121,10 +118,7 @@ namespace Amanotes.Core
|
|
|
121
118
|
public string socialToken;
|
|
122
119
|
public string socialPlatform;
|
|
123
120
|
|
|
124
|
-
internal bool hasLinkSocial
|
|
125
|
-
{
|
|
126
|
-
get { return !string.IsNullOrEmpty(socialPlatform); }
|
|
127
|
-
}
|
|
121
|
+
internal bool hasLinkSocial => !string.IsNullOrEmpty(socialPlatform);
|
|
128
122
|
}
|
|
129
123
|
|
|
130
124
|
[Serializable]
|
|
@@ -135,73 +129,74 @@ namespace Amanotes.Core
|
|
|
135
129
|
public string lon;
|
|
136
130
|
public string query;
|
|
137
131
|
}
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public partial class AmaGDK // AmaPassport
|
|
135
|
+
{
|
|
136
|
+
public partial class AmaPassport // Token Requesting Logic
|
|
140
137
|
{
|
|
141
|
-
private
|
|
142
|
-
private const string PASSPORT_URL = API_URL + "passport/";
|
|
143
|
-
private const string TOKEN_URL = API_URL + "token/";
|
|
144
|
-
|
|
145
|
-
private const string GET_AMA_ID_URL = PASSPORT_URL + "get-ama-id";
|
|
146
|
-
private const string SOCIAL_UNLINK_URL = PASSPORT_URL + "logout";
|
|
147
|
-
private const string INIT_URL = TOKEN_URL + "init";
|
|
148
|
-
private const string REFRESH_URL = TOKEN_URL + "refresh-token";
|
|
149
|
-
|
|
150
|
-
[Serializable] class TokenData
|
|
138
|
+
[Serializable] private class TokenData
|
|
151
139
|
{
|
|
152
140
|
public string expiresIn;
|
|
153
141
|
public string accessToken;
|
|
154
142
|
public string refreshToken;
|
|
155
143
|
}
|
|
156
144
|
|
|
157
|
-
[Serializable] class AmaIDData
|
|
145
|
+
[Serializable] private class AmaIDData
|
|
158
146
|
{
|
|
159
147
|
public string amaId;
|
|
160
148
|
public string amaDeviceId;
|
|
161
149
|
}
|
|
150
|
+
|
|
151
|
+
private const string API_URL = "https://passport.staging.amanotes.io/api/v3/";
|
|
152
|
+
private const string PASSPORT_URL = API_URL + "passport/";
|
|
153
|
+
private const string TOKEN_URL = API_URL + "token/";
|
|
162
154
|
|
|
163
|
-
|
|
155
|
+
private const string GET_AMA_ID_URL = PASSPORT_URL + "get-ama-id";
|
|
156
|
+
private const string SOCIAL_UNLINK_URL = PASSPORT_URL + "logout";
|
|
157
|
+
private const string INIT_URL = TOKEN_URL + "init";
|
|
158
|
+
private const string REFRESH_URL = TOKEN_URL + "refresh-token";
|
|
159
|
+
|
|
160
|
+
private static IEnumerator RequestTokenRoutine()
|
|
164
161
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
string appSecret = _ampConfig.secretKey;
|
|
163
|
+
AmaPassportInfo passport = User.amaPassport;
|
|
164
|
+
bool isRefresh = !string.IsNullOrEmpty(passport.refreshToken);
|
|
165
|
+
|
|
169
166
|
var request = new JsonWebRequest<TokenData>(
|
|
170
|
-
|
|
171
|
-
isRefresh
|
|
172
|
-
|
|
167
|
+
isRefresh ? REFRESH_URL : INIT_URL,
|
|
168
|
+
isRefresh ? JsonUtils.KeyValueToJson("refreshToken", passport.refreshToken)
|
|
169
|
+
: JsonUtils.KeyValueToJson("appSecret", appSecret)
|
|
173
170
|
);
|
|
174
|
-
|
|
171
|
+
|
|
175
172
|
yield return _instance.StartCoroutine(request.Send());
|
|
176
|
-
|
|
177
|
-
var data = request.data;
|
|
178
|
-
if (data == null){
|
|
179
|
-
Debug.LogWarning("data should not be null!");
|
|
180
|
-
}
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
TokenData data = request.data;
|
|
175
|
+
if (data == null) Debug.LogWarning("data should not be null!");
|
|
184
176
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
if (data?.expiresIn != null)
|
|
178
|
+
{
|
|
179
|
+
long expireTime = DateTimeOffset.Now.ToUnixTimeMilliseconds() + int.Parse(data.expiresIn);
|
|
180
|
+
Log("RequestTokenRoutine complete --> accessToken = " + data.accessToken);
|
|
181
|
+
|
|
182
|
+
// Update & save
|
|
183
|
+
passport.accessToken = data.accessToken;
|
|
184
|
+
passport.refreshToken = data.refreshToken;
|
|
185
|
+
passport.expireTime = expireTime;
|
|
186
|
+
}
|
|
189
187
|
User.Save();
|
|
190
188
|
}
|
|
191
189
|
|
|
192
|
-
static IEnumerator GetAmaIDRoutine()
|
|
190
|
+
private static IEnumerator GetAmaIDRoutine()
|
|
193
191
|
{
|
|
194
|
-
|
|
195
|
-
if (string.IsNullOrEmpty(passport.accessToken) || passport.isTokenExpired())
|
|
196
|
-
{
|
|
197
|
-
yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
198
|
-
}
|
|
192
|
+
AmaPassportInfo passport = User.amaPassport;
|
|
193
|
+
if (string.IsNullOrEmpty(passport.accessToken) || passport.isTokenExpired()) yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
199
194
|
|
|
200
|
-
var requestData = new Dictionary<string, object>
|
|
195
|
+
var requestData = new Dictionary<string, object>
|
|
201
196
|
{
|
|
202
|
-
{"amaId", passport.device.amaId},
|
|
203
|
-
{"social", passport.social},
|
|
204
|
-
{"ids", passport.device}
|
|
197
|
+
{ "amaId", passport.device.amaId },
|
|
198
|
+
{ "social", passport.social },
|
|
199
|
+
{ "ids", passport.device }
|
|
205
200
|
};
|
|
206
201
|
|
|
207
202
|
var request = new JsonWebRequest<AmaIDData>(
|
|
@@ -211,24 +206,22 @@ namespace Amanotes.Core
|
|
|
211
206
|
);
|
|
212
207
|
|
|
213
208
|
yield return _instance.StartCoroutine(request.Send());
|
|
214
|
-
|
|
209
|
+
AmaIDData data = request.data;
|
|
215
210
|
|
|
216
211
|
Log("GetAmaIDRoutine complete --> amaId = " + data.amaId);
|
|
212
|
+
|
|
217
213
|
// Update & Save
|
|
218
214
|
passport.device.amaId = data.amaId;
|
|
219
215
|
OnGetAmaIdComplete?.Invoke(data.amaId);
|
|
220
216
|
User.Save();
|
|
221
217
|
}
|
|
222
218
|
|
|
223
|
-
static IEnumerator UnlinkSocialRoutine()
|
|
219
|
+
private static IEnumerator UnlinkSocialRoutine()
|
|
224
220
|
{
|
|
225
|
-
|
|
226
|
-
if (string.IsNullOrEmpty(amaPassport.accessToken) || amaPassport.isTokenExpired())
|
|
227
|
-
{
|
|
228
|
-
yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
229
|
-
}
|
|
221
|
+
AmaPassportInfo amaPassport = User.amaPassport;
|
|
222
|
+
if (string.IsNullOrEmpty(amaPassport.accessToken) || amaPassport.isTokenExpired()) yield return _instance.StartCoroutine(RequestTokenRoutine());
|
|
230
223
|
|
|
231
|
-
|
|
224
|
+
SocialInfo social = amaPassport.social;
|
|
232
225
|
social.socialPlatform = string.Empty;
|
|
233
226
|
social.socialToken = string.Empty;
|
|
234
227
|
|
|
@@ -239,14 +232,14 @@ namespace Amanotes.Core
|
|
|
239
232
|
);
|
|
240
233
|
|
|
241
234
|
yield return _instance.StartCoroutine(request.Send());
|
|
242
|
-
|
|
235
|
+
AmaIDData data = request.data;
|
|
243
236
|
|
|
244
237
|
// Update & Save
|
|
245
238
|
Log("[Unlink] amaId: " + data.amaId);
|
|
246
239
|
amaPassport.device.amaId = data.amaId;
|
|
247
240
|
User.Save();
|
|
248
241
|
}
|
|
249
|
-
|
|
242
|
+
|
|
250
243
|
// Internal static
|
|
251
244
|
private static void LinkSocialAccount(string platform, string token)
|
|
252
245
|
{
|
|
@@ -290,10 +283,8 @@ namespace Amanotes.Core
|
|
|
290
283
|
_instance.StartCoroutine(GetAmaIDRoutine());
|
|
291
284
|
}
|
|
292
285
|
}
|
|
293
|
-
|
|
294
|
-
public partial class AmaPassport //Support
|
|
286
|
+
public partial class AmaPassport // Location support
|
|
295
287
|
{
|
|
296
|
-
|
|
297
288
|
internal static void GetLocation(Action oncomplete)
|
|
298
289
|
{
|
|
299
290
|
_instance.StartCoroutine(GetIP(oncomplete));
|
|
@@ -315,12 +306,10 @@ namespace Amanotes.Core
|
|
|
315
306
|
DeviceInfo device = User.amaPassport.device;
|
|
316
307
|
device.country = geoData.country;
|
|
317
308
|
device.ipAddress = geoData.query;
|
|
318
|
-
device.location = new Location
|
|
319
|
-
|
|
320
|
-
else
|
|
321
|
-
{
|
|
309
|
+
device.location = new Location
|
|
310
|
+
{ lat = geoData.lat, lon = geoData.lon };
|
|
311
|
+
} else
|
|
322
312
|
LogWarning("Get location failed: " + request.error);
|
|
323
|
-
}
|
|
324
313
|
Log("Get GeoData completed");
|
|
325
314
|
onComplete?.Invoke();
|
|
326
315
|
}
|
|
@@ -328,35 +317,44 @@ namespace Amanotes.Core
|
|
|
328
317
|
|
|
329
318
|
public partial class AmaPassport // public APIs
|
|
330
319
|
{
|
|
331
|
-
static
|
|
320
|
+
private static AmaPassportAdapterConfig _ampConfig;
|
|
321
|
+
|
|
322
|
+
private static ActionQueue actionQueue;
|
|
332
323
|
public static Action<Action> GetAdvertisingIdHook;
|
|
333
324
|
public static Action<Action> GetLocationHook;
|
|
334
325
|
public static Action<Action> ATTHook;
|
|
335
326
|
public static Action<string> OnGetAmaIdComplete;
|
|
336
|
-
private static bool isInQueue
|
|
327
|
+
private static bool isInQueue;
|
|
337
328
|
|
|
338
|
-
public static string AmaId
|
|
329
|
+
public static string AmaId => User.amaPassport.device.amaId;
|
|
330
|
+
|
|
331
|
+
internal static void Init()
|
|
339
332
|
{
|
|
340
|
-
|
|
333
|
+
var adapter = Adapter.GetSingleAdapter<IAmaPassportAdapter>();
|
|
334
|
+
_ampConfig = (adapter as AdapterContext)?.GetAdapterConfig<AmaPassportAdapterConfig>();
|
|
341
335
|
}
|
|
342
336
|
|
|
343
337
|
public static void LinkWithFacebook(string accessToken)
|
|
344
338
|
{
|
|
339
|
+
if (_ampConfig == null) return;
|
|
345
340
|
LinkSocialAccount("facebook", accessToken);
|
|
346
341
|
}
|
|
347
342
|
|
|
348
343
|
public static void LinkWithGoogle(string idToken)
|
|
349
344
|
{
|
|
345
|
+
if (_ampConfig == null) return;
|
|
350
346
|
LinkSocialAccount("google", idToken);
|
|
351
347
|
}
|
|
352
348
|
|
|
353
349
|
public static void LinkWithApple(string identityToken)
|
|
354
350
|
{
|
|
351
|
+
if (_ampConfig == null) return;
|
|
355
352
|
LinkSocialAccount("apple", identityToken);
|
|
356
353
|
}
|
|
357
354
|
|
|
358
355
|
public static void UnlinkSocialAccount()
|
|
359
356
|
{
|
|
357
|
+
if (_ampConfig == null) return;
|
|
360
358
|
if (!User.amaPassport.social.hasLinkSocial)
|
|
361
359
|
{
|
|
362
360
|
LogWarning("Social has not linked");
|
|
@@ -370,20 +368,20 @@ namespace Amanotes.Core
|
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
_instance.StartCoroutine(UnlinkSocialRoutine());
|
|
373
|
-
}
|
|
371
|
+
}
|
|
374
372
|
|
|
375
373
|
public static void RequestAmaID()
|
|
376
374
|
{
|
|
377
|
-
|
|
378
|
-
|
|
375
|
+
if (_ampConfig == null) return;
|
|
376
|
+
DeviceInfo device = User.amaPassport.device;
|
|
379
377
|
|
|
380
|
-
if (string.IsNullOrEmpty(
|
|
378
|
+
if (string.IsNullOrEmpty(_ampConfig.secretKey))
|
|
381
379
|
{
|
|
382
|
-
LogWarning($"Invalid secretKey: {
|
|
380
|
+
LogWarning($"Invalid secretKey: {_ampConfig.secretKey}");
|
|
383
381
|
return;
|
|
384
382
|
}
|
|
385
383
|
|
|
386
|
-
if (!
|
|
384
|
+
if (!_ampConfig.enableAmaPassport)
|
|
387
385
|
{
|
|
388
386
|
LogWarning("AmaPassport is disabled!");
|
|
389
387
|
return;
|
|
@@ -398,7 +396,7 @@ namespace Amanotes.Core
|
|
|
398
396
|
GetDeviceInfo(DoRequestAmaID);
|
|
399
397
|
}
|
|
400
398
|
|
|
401
|
-
static void GetDeviceInfo(Action getDeviceInfoComplete)
|
|
399
|
+
private static void GetDeviceInfo(Action getDeviceInfoComplete)
|
|
402
400
|
{
|
|
403
401
|
if (isInQueue)
|
|
404
402
|
{
|
|
@@ -407,7 +405,7 @@ namespace Amanotes.Core
|
|
|
407
405
|
}
|
|
408
406
|
isInQueue = true;
|
|
409
407
|
|
|
410
|
-
|
|
408
|
+
DeviceInfo device = User.amaPassport.device;
|
|
411
409
|
device.deviceModel = SystemInfo.deviceModel;
|
|
412
410
|
device.deviceName = SystemInfo.deviceName;
|
|
413
411
|
device.processorType = SystemInfo.processorType;
|
|
@@ -417,17 +415,15 @@ namespace Amanotes.Core
|
|
|
417
415
|
device.operatingSystem = SystemInfo.operatingSystem;
|
|
418
416
|
if (Application.platform == RuntimePlatform.Android)
|
|
419
417
|
device.androidId = SystemInfo.deviceUniqueIdentifier;
|
|
420
|
-
else if (Application.platform == RuntimePlatform.IPhonePlayer)
|
|
421
|
-
device.idfv = SystemInfo.deviceUniqueIdentifier;
|
|
418
|
+
else if (Application.platform == RuntimePlatform.IPhonePlayer) device.idfv = SystemInfo.deviceUniqueIdentifier;
|
|
422
419
|
|
|
423
|
-
var config = Config.amaPassport;
|
|
424
420
|
actionQueue = new ActionQueue(getDeviceInfoComplete);
|
|
425
421
|
actionQueue.EnqueueAction(ATTHook);
|
|
426
422
|
|
|
427
|
-
if (
|
|
428
|
-
if (
|
|
423
|
+
if (_ampConfig.injectLocation) actionQueue.EnqueueAction(GetLocationHook ?? GetLocation);
|
|
424
|
+
if (_ampConfig.injectAdvertisingId) actionQueue.EnqueueAction(GetAdvertisingIdHook);
|
|
429
425
|
actionQueue.StartQueue();
|
|
430
426
|
}
|
|
431
427
|
}
|
|
432
428
|
}
|
|
433
|
-
}
|
|
429
|
+
}
|
|
@@ -66,7 +66,7 @@ namespace Amanotes.Core
|
|
|
66
66
|
return defaultValue;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
public static T WriteConfigTo<T>(T config = null) where T : class, new
|
|
69
|
+
public static T WriteConfigTo<T>(T config = null) where T : class, new()
|
|
70
70
|
{
|
|
71
71
|
return ParseConfig<T>(config);
|
|
72
72
|
}
|
|
@@ -88,7 +88,6 @@ namespace Amanotes.Core
|
|
|
88
88
|
SaveCache,
|
|
89
89
|
|
|
90
90
|
LoadCache,
|
|
91
|
-
LoadDefaultFile,
|
|
92
91
|
LoadDefaultAsset,
|
|
93
92
|
|
|
94
93
|
Success,
|
|
@@ -96,8 +95,8 @@ namespace Amanotes.Core
|
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
static Dictionary<string, string> dictConfig = new Dictionary<string, string>();
|
|
99
|
-
static string fileName = $"{nameof(RemoteConfig)}.kv";
|
|
100
|
-
static string
|
|
98
|
+
static string fileName = $"{nameof(RemoteConfig)}.kv";
|
|
99
|
+
static string base64Prefix = "base64:";
|
|
101
100
|
|
|
102
101
|
static FetchState _state = FetchState.None;
|
|
103
102
|
internal static FetchState State { get { return _state; } }
|
|
@@ -108,8 +107,7 @@ namespace Amanotes.Core
|
|
|
108
107
|
{ FetchState.CheckInternet, new Action[]{ LoadCache, Fetch}},
|
|
109
108
|
{ FetchState.Fetch, new Action[]{ LoadCache, SaveCache}},
|
|
110
109
|
{ FetchState.SaveCache, new Action[]{ SetDone }},
|
|
111
|
-
{ FetchState.LoadCache, new Action[]{
|
|
112
|
-
{ FetchState.LoadDefaultFile, new Action[]{ LoadDefaultAsset, SetDone}},
|
|
110
|
+
{ FetchState.LoadCache, new Action[]{ LoadDefaultAsset, SetDone}},
|
|
113
111
|
{ FetchState.LoadDefaultAsset, new Action[]{ SetFail, SetDone}}
|
|
114
112
|
};
|
|
115
113
|
|
|
@@ -175,7 +173,7 @@ namespace Amanotes.Core
|
|
|
175
173
|
StringBuilder sb = new StringBuilder();
|
|
176
174
|
foreach (var c in dictConfig)
|
|
177
175
|
{
|
|
178
|
-
sb.AppendLine($"{c.Key}\t{c.Value}");
|
|
176
|
+
sb.AppendLine($"{c.Key}\t{Encode(c.Value)}");
|
|
179
177
|
}
|
|
180
178
|
|
|
181
179
|
var filePath = FileUtils.GetPath(fileName);
|
|
@@ -212,7 +210,7 @@ namespace Amanotes.Core
|
|
|
212
210
|
}
|
|
213
211
|
string key = line.Substring(0, idx);
|
|
214
212
|
string value = line.Substring(idx + 1);
|
|
215
|
-
dictConfig.Add(key, value);
|
|
213
|
+
dictConfig.Add(key, Decode(value));
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
216
|
Source = RemoteConfigSource.Cache;
|
|
@@ -229,24 +227,6 @@ namespace Amanotes.Core
|
|
|
229
227
|
NextState(true);
|
|
230
228
|
}
|
|
231
229
|
|
|
232
|
-
static void LoadDefaultFile()
|
|
233
|
-
{
|
|
234
|
-
_state = FetchState.LoadDefaultFile;
|
|
235
|
-
|
|
236
|
-
var defaultConfigFile = Resources.Load<TextAsset>(defaultConfigFileName);
|
|
237
|
-
if (defaultConfigFile == null)
|
|
238
|
-
{
|
|
239
|
-
NextState(false);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
dictConfig = JsonToDictionary(defaultConfigFile.text);
|
|
244
|
-
|
|
245
|
-
Source = RemoteConfigSource.DefaultFile;
|
|
246
|
-
Log("[RemoteConfig] Load from default file");
|
|
247
|
-
NextState(true);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
230
|
static void LoadDefaultAsset()
|
|
251
231
|
{
|
|
252
232
|
_state = FetchState.LoadDefaultAsset;
|
|
@@ -280,33 +260,23 @@ namespace Amanotes.Core
|
|
|
280
260
|
_state = FetchState.Fail;
|
|
281
261
|
onAdapterInitCompleteCallback(false);
|
|
282
262
|
onFetchCompleted?.Invoke(false);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
static string Encode(string s)
|
|
266
|
+
{
|
|
267
|
+
if (!s.Contains("\n"))
|
|
268
|
+
return s;
|
|
269
|
+
|
|
270
|
+
return $"{base64Prefix}{Convert.ToBase64String(Encoding.UTF8.GetBytes(s))}";
|
|
283
271
|
}
|
|
284
272
|
|
|
285
|
-
static
|
|
273
|
+
static string Decode(string s)
|
|
286
274
|
{
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (idx < 0)
|
|
293
|
-
{
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
string key = lines[i].Substring(0, idx - 1).Trim().Trim('"');
|
|
297
|
-
string value = "";
|
|
298
|
-
if (idx == lines.Length - 1)
|
|
299
|
-
{
|
|
300
|
-
value = lines[i].Substring(idx + 1).Trim().Trim('"');
|
|
301
|
-
}
|
|
302
|
-
else
|
|
303
|
-
{
|
|
304
|
-
value = lines[i].Substring(idx + 1).Trim();
|
|
305
|
-
value = value.Substring(1, value.Length - 3);
|
|
306
|
-
}
|
|
307
|
-
dictResult[key] = value;
|
|
308
|
-
}
|
|
309
|
-
return dictResult;
|
|
275
|
+
if (!s.StartsWith(base64Prefix, StringComparison.InvariantCulture))
|
|
276
|
+
return s;
|
|
277
|
+
|
|
278
|
+
s = s.Remove(0, base64Prefix.Length);
|
|
279
|
+
return Encoding.UTF8.GetString(Convert.FromBase64String(s));
|
|
310
280
|
}
|
|
311
281
|
}
|
|
312
282
|
}
|
|
@@ -317,8 +287,7 @@ namespace Amanotes.Core
|
|
|
317
287
|
{
|
|
318
288
|
if (AmaGDK.RemoteConfig.State != AmaGDK.RemoteConfig.FetchState.None)
|
|
319
289
|
{
|
|
320
|
-
LogWarning($"[RemoteConfig] Current state {AmaGDK.RemoteConfig.State.ToString()}\
|
|
321
|
-
$"Cannot start to initialize");
|
|
290
|
+
LogWarning($"[RemoteConfig] Current state {AmaGDK.RemoteConfig.State.ToString()}\nCannot start to initialize");
|
|
322
291
|
return;
|
|
323
292
|
}
|
|
324
293
|
AmaGDK.RemoteConfig.onAdapterInitCompleteCallback = onCompleteCallback;
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -9,7 +9,7 @@ namespace Amanotes.Core
|
|
|
9
9
|
{
|
|
10
10
|
public partial class AmaGDK : MonoBehaviour
|
|
11
11
|
{
|
|
12
|
-
public const string VERSION = "0.2.
|
|
12
|
+
public const string VERSION = "0.2.6";
|
|
13
13
|
|
|
14
14
|
internal static AmaGDK _instance;
|
|
15
15
|
internal static Status _status = Status.None;
|
|
@@ -95,10 +95,11 @@ namespace Amanotes.Core
|
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
Log(
|
|
98
|
+
Log($"Adapter {adapter.adapterId} {(adapter.IsReady ? "initiated!" : "is not ready!")}");
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// Init modules (Adapter managers)
|
|
102
|
+
AmaPassport.Init();
|
|
102
103
|
Analytics.Init();
|
|
103
104
|
Ads.Init();
|
|
104
105
|
|
package/package.json
CHANGED
|
Binary file
|