com.amanotes.gdk 0.2.81-alpha.8 → 0.2.84

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/Editor/Extra/SDKVersionTracking.cs +20 -1
  3. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  4. package/Extra/AutoEventQC.unitypackage +0 -0
  5. package/Extra/CheckDiskSpace.unitypackage +0 -0
  6. package/Extra/Consent.unitypackage +0 -0
  7. package/Extra/CrashlyticHook.unitypackage +0 -0
  8. package/Extra/ForceUpdate.unitypackage +0 -0
  9. package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
  10. package/Extra/PostProcessor.unitypackage +0 -0
  11. package/Packages/AmaGDKConfig.unitypackage +0 -0
  12. package/Packages/AmaGDKExample.unitypackage +0 -0
  13. package/Packages/AmaGDKTest.unitypackage +0 -0
  14. package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
  15. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  16. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  17. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  18. package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
  19. package/Packages/IronSourceAdapter.unitypackage +0 -0
  20. package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
  21. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  22. package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
  23. package/Runtime/Ad/AdLogic.cs +44 -41
  24. package/Runtime/Ad/AdModuleConfig.cs +3 -0
  25. package/Runtime/Ad/AmaGDK.Ads.cs +2 -1
  26. package/Runtime/AmaGDK.Analytics.cs +14 -7
  27. package/Runtime/AmaGDK.IAP.cs +35 -60
  28. package/Runtime/AmaGDK.RemoteConfig.cs +5 -5
  29. package/Runtime/AmaGDK.UserProfile.cs +2 -2
  30. package/Runtime/AmaGDK.asmdef +3 -1
  31. package/Runtime/AmaGDK.cs +1 -1
  32. package/Runtime/Consent/AmaGDK.Consent.cs +35 -59
  33. package/Runtime/Core/GDKDebug.cs +43 -24
  34. package/Runtime/Internal/AmaGDK.Utils.cs +1 -1
  35. package/Runtime/Internal/ForceQuitMonitor.cs +1 -1
  36. package/Runtime/Utils/GDKFileUtils.cs +240 -104
  37. package/Runtime/Utils/GDKUtils.cs +33 -0
  38. package/package.json +30 -18
  39. package/Runtime/Consent/GDKPrivacyButton.cs +0 -25
  40. package/Runtime/Consent/GDKPrivacyButton.cs.meta +0 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [0.2.84] - 2025-03-17
2
+ - [Fix] Attach JNI thread
3
+
4
+ ## [0.2.83] - 2025-03-12
5
+
6
+
7
+ ## [0.2.82] - 2025-03-12
8
+ - [Fix] Missing DoOnMainThread for ConsentInformation update
9
+ - [Fix] Send GDKVersionTracking only for Android/iOS
10
+ - [Dev] Rename Remote Config Data Source
11
+ - [Fix] Improve disk space checking with thead pool
12
+ - [Dev] Refactor DiskSpacePopup
13
+ - [Fix] Add missing scope registry for integration test
14
+ - [Dev] Add UniTask Dependency
15
+
16
+ ## [0.2.81] - 2025-01-16
17
+ - [Fix] GDK Version
18
+ - [Dev] Improve Google CMP
19
+ - [Fix] Obsolete IronSource events
20
+
1
21
  ## [0.2.80] - 2024-11-13
2
22
  - [Dev] Don't use obsolete functions
3
23
  - [Dev] Add CrashlyticHook
@@ -2,6 +2,7 @@ using System;
2
2
  using System.Collections.Generic;
3
3
  using System.IO;
4
4
  using System.Linq;
5
+ using System.Net;
5
6
  using System.Net.Http;
6
7
  using System.Text;
7
8
  using System.Xml;
@@ -269,6 +270,19 @@ namespace Amanotes.Editor
269
270
  [PostProcessBuild(999)]
270
271
  public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
271
272
  {
273
+ if (target != BuildTarget.Android && target != BuildTarget.iOS) return;
274
+
275
+ var productName = Application.productName?.Trim().ToLowerInvariant();
276
+ var appId = PlayerSettings.applicationIdentifier?.ToLowerInvariant();
277
+ var bundleVersion = PlayerSettings.bundleVersion?.Trim();
278
+
279
+ if (string.IsNullOrEmpty(productName) || productName == "my project" ||
280
+ string.IsNullOrEmpty(appId) || appId.StartsWith("com.defaultcompany") || appId.StartsWith("com.unity-technologies") ||
281
+ string.IsNullOrEmpty(bundleVersion) || bundleVersion == "0")
282
+ {
283
+ return;
284
+ }
285
+
272
286
  var rawData = _dicThirdPartyVersion
273
287
  .Concat(_dicExtraVersion)
274
288
  .Concat(_dicIronSourceAdapterVersion.ToDictionary(kvp => kvp.Key, kvp => (object)("IS_" + kvp.Value)))
@@ -318,7 +332,12 @@ namespace Amanotes.Editor
318
332
  else
319
333
  {
320
334
  string errorData = await response.Content.ReadAsStringAsync();
321
- Debug.LogError($"AmaGDK | [SDKVersionTracking] Status code {response.StatusCode} Error Response: {errorData}");
335
+ string errorMessage = $"AmaGDK | [SDKVersionTracking] Status code {response.StatusCode} Error Response: {errorData}";
336
+ if ((int)response.StatusCode == 409)
337
+ {
338
+ throw new Exception(errorMessage);
339
+ }
340
+ Debug.LogError(errorMessage);
322
341
  }
323
342
  }
324
343
  catch (HttpRequestException e)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,7 +8,6 @@ namespace Amanotes.Core.Internal
8
8
  {
9
9
  public abstract class AdLogic
10
10
  {
11
- private const int MAX_FRAMES_WAIT_FOR_CALLBACK = 60;
12
11
  protected AdModuleConfig adConfig => Config.ad;
13
12
  protected AdShowContext context => Ads.context;
14
13
 
@@ -256,20 +255,18 @@ namespace Amanotes.Core.Internal
256
255
  }
257
256
  };
258
257
  unityCallbacks.OnApplicationFocus += onApplicationFocusCallback;
259
- int counter = 0;
260
258
  while (context != null && !context.potentiallyCompleted)
261
259
  {
262
260
  if (hasFocusAgain && hasOutOfFocus)
263
261
  {
264
- // Start counting frames only after closed the ad
265
- counter++;
266
- }
267
- if (counter > MAX_FRAMES_WAIT_FOR_CALLBACK)
268
- {
269
- // Timeout reached, force close the ad
270
- LogError("Force close the ad");
271
- StopShowAd();
272
- break;
262
+ // Start counting only after closed the ad
263
+ yield return GDKUtils.WaitForSecondsRealtime(Config.ad.adCallBackTimeOut);
264
+ if (context != null && !context.potentiallyCompleted)
265
+ {
266
+ LogError("Force close the ad");
267
+ StopShowAd();
268
+ break;
269
+ }
273
270
  }
274
271
  yield return null;
275
272
  }
@@ -351,24 +348,27 @@ namespace Amanotes.Core.Internal
351
348
 
352
349
  private void TriggerBeforeAdShow()
353
350
  {
354
- bool willSaveVolume = Config.ad.autoMute
355
- && AudioListener.volume > 0
356
- && Ads._savedVolume < 0;
351
+ if (Application.platform == RuntimePlatform.IPhonePlayer)
352
+ {
353
+ bool willSaveVolume = Config.ad.autoMute
354
+ && AudioListener.volume > 0
355
+ && Ads._savedVolume < 0;
357
356
 
358
- bool willSaveTimeScale = Config.ad.autoTimeScale
359
- && Time.timeScale > 0
360
- && Ads._savedTimeScale < 0;
357
+ bool willSaveTimeScale = Config.ad.autoTimeScale
358
+ && Time.timeScale > 0
359
+ && Ads._savedTimeScale < 0;
361
360
 
362
- if (willSaveVolume)
363
- {
364
- Ads._savedVolume = AudioListener.volume;
365
- AudioListener.volume = 0;
366
- }
361
+ if (willSaveVolume)
362
+ {
363
+ Ads._savedVolume = AudioListener.volume;
364
+ AudioListener.volume = 0;
365
+ }
367
366
 
368
- if (willSaveTimeScale)
369
- {
370
- Ads._savedTimeScale = Time.timeScale;
371
- Time.timeScale = 0;
367
+ if (willSaveTimeScale)
368
+ {
369
+ Ads._savedTimeScale = Time.timeScale;
370
+ Time.timeScale = 0;
371
+ }
372
372
  }
373
373
 
374
374
  dispatcher.Dispatch(_isInterstitial ? AmaGDK.Event.INTER_SHOW_BEGIN : AmaGDK.Event.REWARD_VIDEO_SHOW_BEGIN);
@@ -377,24 +377,27 @@ namespace Amanotes.Core.Internal
377
377
 
378
378
  private void TriggerOnAfterAdShow()
379
379
  {
380
- bool willRestoreVolume = Config.ad.autoMute
381
- && AudioListener.volume == 0
382
- && Ads._savedVolume > 0;
380
+ if (Application.platform == RuntimePlatform.IPhonePlayer)
381
+ {
382
+ bool willRestoreVolume = Config.ad.autoMute
383
+ && Mathf.Approximately(AudioListener.volume, 0)
384
+ && Ads._savedVolume > 0;
383
385
 
384
- bool willRestoreTimeScale = Config.ad.autoTimeScale
385
- && Time.timeScale == 0
386
- && Ads._savedTimeScale > 0;
386
+ bool willRestoreTimeScale = Config.ad.autoTimeScale
387
+ && Mathf.Approximately(Time.timeScale, 0)
388
+ && Ads._savedTimeScale > 0;
387
389
 
388
- if (willRestoreVolume)
389
- {
390
- AudioListener.volume = Ads._savedVolume;
391
- Ads._savedVolume = -1;
392
- }
390
+ if (willRestoreVolume)
391
+ {
392
+ AudioListener.volume = Ads._savedVolume;
393
+ Ads._savedVolume = -1;
394
+ }
393
395
 
394
- if (willRestoreTimeScale)
395
- {
396
- Time.timeScale = Ads._savedTimeScale;
397
- Ads._savedTimeScale = -1;
396
+ if (willRestoreTimeScale)
397
+ {
398
+ Time.timeScale = Ads._savedTimeScale;
399
+ Ads._savedTimeScale = -1;
400
+ }
398
401
  }
399
402
 
400
403
  bool isSuccess = _showState == ShowAdsState.ShowSuccess;
@@ -45,6 +45,9 @@ namespace Amanotes.Core.Internal
45
45
  [Header("EDITOR")]
46
46
  [Tooltip("Only applicable in Editor\n0 = 0% success\n1 = 100% success")]
47
47
  [Range(0f, 1f)] public float rewardAdShowSuccessRate = 1;
48
+
49
+ [Tooltip(("The maximum time (in seconds) to wait for the callback response after the ad activity has finished and the app returns to the Unity activity (default = 5s)"))]
50
+ public float adCallBackTimeOut = 5f;
48
51
  }
49
52
 
50
53
  public partial class ConfigAsset
@@ -93,7 +93,7 @@ namespace Amanotes.Core
93
93
 
94
94
  internal void Save()
95
95
  {
96
- this.SaveJsonToFile();
96
+ this.SaveJsonToFile(false);
97
97
  }
98
98
  }
99
99
 
@@ -345,6 +345,7 @@ namespace Amanotes.Core.Internal
345
345
  {
346
346
  protected AdShowContext context => Ads.context;
347
347
  protected AdModuleConfig moduleConfig => Config.ad;
348
+ public Dictionary<string, object> userData => context?.userData;
348
349
 
349
350
  // APIs
350
351
  internal protected abstract AdLogic interstitial { get; }
@@ -130,12 +130,11 @@ namespace Amanotes.Core
130
130
  if (Config.analytics.autoFlushEventDetail)
131
131
  {
132
132
  LogWarning("[Analytics] This function FlushEventDetails() is not supposed to be called manually!");
133
- return;
134
133
  }
135
134
 
136
135
  if (!localData._dirty) return;
137
136
  localData._dirty = false;
138
- localData.SaveJsonToFile();
137
+ localData.SaveJsonToFile(false);
139
138
  }
140
139
 
141
140
  public static IEventParamsBuilder LogFunnelEvent(string eventName, string signature = "")
@@ -648,7 +647,12 @@ namespace Amanotes.Core
648
647
  internal static void PostPrepareEventProcess(EventParams eventData)
649
648
  {
650
649
  if (!eventData.parameters.ContainsKey("ama_device_id"))
651
- eventData.AddParam("ama_device_id", User.AmaDeviceId);
650
+ {
651
+ if (!string.IsNullOrWhiteSpace(User.AmaDeviceId))
652
+ {
653
+ eventData.AddParam("ama_device_id", User.AmaDeviceId);
654
+ }
655
+ }
652
656
  }
653
657
 
654
658
  internal static bool ShouldSendEvent(EventParams eventData)
@@ -715,10 +719,13 @@ namespace Amanotes.Core
715
719
  {
716
720
  sb.Append(eventNameToSend);
717
721
  sb.Append("\t");
718
- for (var i = 0; i < adapters.Count; i++)
722
+ if (adapters != null && adapters.Count > 0)
719
723
  {
720
- sb.Append(adapters[i]);
721
- if (i < adapters.Count - 1) sb.Append(",");
724
+ for (var i = 0; i < adapters.Count; i++)
725
+ {
726
+ sb.Append(adapters[i]);
727
+ if (i < adapters.Count - 1) sb.Append(",");
728
+ }
722
729
  }
723
730
  sb.Append("\t");
724
731
  sb.AppendLine(eventParamsInJSON);
@@ -843,7 +850,7 @@ namespace Amanotes.Core
843
850
  if (!Config.analytics.autoFlushEventDetail) return;
844
851
  if (!_dirty) return;
845
852
  _dirty = false;
846
- this.SaveJsonToFile();
853
+ this.SaveJsonToFile(false);
847
854
  }
848
855
 
849
856
  internal void UpdateMigrationLog()
@@ -21,7 +21,10 @@ namespace Amanotes.Core
21
21
  public static DateTime? SubscriptionExpiredDate => localData.SubscriptionExpiredDate;
22
22
  public static DateTime? UnsubscribedDate => localData.UnsubscribedDate;
23
23
  public static readonly Dictionary<string, ProductInfo> AllProducts = new Dictionary<string, ProductInfo>();
24
+
24
25
  private const string DATE_FORMAT = "yyyy/MM/yy HH:mm:ss";
26
+ private static readonly GDKTaskTracker<bool> _syncTaskTracker = new GDKTaskTracker<bool>();
27
+ private static readonly GDKTaskTracker _getProductsTaskTracker = new GDKTaskTracker();
25
28
 
26
29
  public static void SetCallback_OnModuleReady(Action onReady)
27
30
  {
@@ -37,42 +40,32 @@ namespace Amanotes.Core
37
40
  _onModuleReady += onReady;
38
41
  }
39
42
 
40
- public static void SetCallback_OnGetProductsComplete(Action onComplete)
41
- {
42
- if (onComplete == null) return;
43
-
44
- if (isGetProductComplete)
45
- {
46
- onComplete();
47
- return;
48
- }
49
-
50
- _onGetProductsComplete -= onComplete;
51
- _onGetProductsComplete += onComplete;
52
- }
53
-
54
- public static void SetCallback_OnGetCustomerInfoComplete(Action onComplete)
55
- {
56
- if (onComplete == null) return;
57
-
58
- if (isGetCustomerInfoComplete)
59
- {
60
- onComplete();
61
- return;
62
- }
63
-
64
- _onGetCustomerInfoComplete -= onComplete;
65
- _onGetCustomerInfoComplete += onComplete;
66
- }
67
-
68
43
  public static void SyncCustomerInfo(Action<bool> onComplete = null)
69
44
  {
70
- if (_adapter == null)
45
+ if (Adapter == null)
71
46
  {
72
47
  onComplete?.Invoke(false);
73
48
  return;
74
49
  }
75
- _adapter.SyncCustomerInfo(onComplete);
50
+
51
+ _syncTaskTracker.RegisterOnCompleteCallback(onComplete);
52
+ if (_syncTaskTracker.HasStarted) return;
53
+
54
+ _syncTaskTracker.MarkStarted();
55
+ Adapter.SyncCustomerInfo(getSuccess =>
56
+ {
57
+ if (getSuccess)
58
+ {
59
+ localData.Sync();
60
+ _syncTaskTracker.MarkCompleted(true);
61
+ }
62
+ else
63
+ {
64
+ _syncTaskTracker.MarkCompleted(false);
65
+ _syncTaskTracker.Reset();
66
+ LogWarning("[IAP] Fail to sync customer info. Please try again later.");
67
+ }
68
+ });
76
69
  }
77
70
 
78
71
  public static ISetupBuilder GetProducts(bool appendExistingList = false)
@@ -181,13 +174,8 @@ namespace Amanotes.Core
181
174
  }
182
175
  }
183
176
 
184
- private static bool isGetProductComplete;
185
- private static bool isGetCustomerInfoComplete;
186
- private static bool IsModuleReady => isGetProductComplete && isGetCustomerInfoComplete;
187
- private static Action _onGetProductsComplete;
188
- private static Action _onGetCustomerInfoComplete;
177
+ private static bool IsModuleReady => _syncTaskTracker.HasCompleted && _getProductsTaskTracker.HasCompleted;
189
178
  private static Action _onModuleReady;
190
-
191
179
  internal static bool InitModule()
192
180
  {
193
181
  _adapter = Adapter2.GetAdapter<IAPAdapter>();
@@ -199,14 +187,8 @@ namespace Amanotes.Core
199
187
  internal static void StartModule()
200
188
  {
201
189
  if (_adapter == null) return;
202
- _adapter.SyncCustomerInfo(
203
- success =>
204
- {
205
- isGetCustomerInfoComplete = true;
206
- GDKUtils.SafeInvokeAndClear(ref _onGetCustomerInfoComplete);
207
- if (IsModuleReady) GDKUtils.SafeInvokeAndClear(ref _onModuleReady);
208
- });
209
- localData.Sync();
190
+ SyncCustomerInfo(_ => CheckModuleReady());
191
+ _getProductsTaskTracker.MarkStarted();
210
192
  if (Config.iap.autoGetProducts)
211
193
  {
212
194
  GetProducts()
@@ -218,11 +200,15 @@ namespace Amanotes.Core
218
200
  OnGetProductsComplete();
219
201
  }
220
202
  }
221
-
203
+
222
204
  private static void OnGetProductsComplete()
223
205
  {
224
- isGetProductComplete = true;
225
- GDKUtils.SafeInvokeAndClear(ref _onGetProductsComplete);
206
+ _getProductsTaskTracker.MarkCompleted();
207
+ CheckModuleReady();
208
+ }
209
+
210
+ private static void CheckModuleReady()
211
+ {
226
212
  if (IsModuleReady) GDKUtils.SafeInvokeAndClear(ref _onModuleReady);
227
213
  }
228
214
  }
@@ -284,19 +270,8 @@ namespace Amanotes.Core
284
270
  }
285
271
  }
286
272
 
287
- public void Sync()
273
+ internal void Sync()
288
274
  {
289
- GDKUtils.StartCoroutine(SyncRoutine());
290
- }
291
-
292
- IEnumerator SyncRoutine()
293
- {
294
- if (Adapter == null)
295
- {
296
- LogWarning("[IAP] Adapter is not available");
297
- yield break;
298
- }
299
- yield return new WaitUntil(() => Adapter.IsReady);
300
275
  activeSubscriptionId = Adapter.GetActiveSubscriptionId();
301
276
  subscriptionPeriodType = Adapter.GetSubscriptionPeriodType();
302
277
  purchasedProducts = Adapter.GetPurchasedProducts();
@@ -306,7 +281,7 @@ namespace Amanotes.Core
306
281
  subscriptionExpiredDate = _subscriptionExpiredDate?.ToString(DATE_FORMAT);
307
282
  _unsubscribedDate = Adapter.GetUnsubscribedDate();
308
283
  unsubscribedDate = _unsubscribedDate?.ToString(DATE_FORMAT);
309
- this.SaveJsonToFile();
284
+ this.SaveJsonToFile(false);
310
285
  }
311
286
  }
312
287
  }
@@ -20,8 +20,8 @@ namespace Amanotes.Core
20
20
  public enum RemoteConfigSource
21
21
  {
22
22
  None,
23
- Cache,
24
- Local,
23
+ Embed,
24
+ LocalCache,
25
25
  Internet
26
26
  }
27
27
 
@@ -235,7 +235,7 @@ namespace Amanotes.Core
235
235
  }
236
236
 
237
237
  string filePath = GDKFileUtils.GetPath(fileName);
238
- GDKFileUtils.Save(filePath, sb.ToString());
238
+ GDKFileUtils.Save(filePath, sb.ToString(), false);
239
239
  GDKPool.Return(sb);
240
240
 
241
241
  Log($"[RemoteConfig] Saved remote config to {filePath}");
@@ -294,7 +294,7 @@ namespace Amanotes.Core
294
294
  DictConfig.Add(key, Decode(value));
295
295
  }
296
296
  }
297
- Source = RemoteConfigSource.Local;
297
+ Source = RemoteConfigSource.LocalCache;
298
298
  Log("[RemoteConfig] Load from cache");
299
299
  }
300
300
  catch (Exception ex)
@@ -332,7 +332,7 @@ namespace Amanotes.Core
332
332
  {
333
333
  DictConfig.Add(item.key, item.value);
334
334
  }
335
- Source = RemoteConfigSource.Cache;
335
+ Source = RemoteConfigSource.Embed;
336
336
  Log("[RemoteConfig] Load from embed asset");
337
337
  NextState(true);
338
338
  }
@@ -33,14 +33,14 @@ namespace Amanotes.Core
33
33
  private bool _dirty = false;
34
34
  private void Save()
35
35
  {
36
- this.SaveJsonToFile();
36
+ this.SaveJsonToFile(false);
37
37
  }
38
38
 
39
39
  private void SaveIfDirty()
40
40
  {
41
41
  if (!_dirty) return;
42
42
  _dirty = false;
43
- this.SaveJsonToFile();
43
+ this.SaveJsonToFile(false);
44
44
  }
45
45
  }
46
46
 
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "AmaGDK",
3
3
  "rootNamespace": "",
4
- "references": [],
4
+ "references": [
5
+ "UniTask"
6
+ ],
5
7
  "includePlatforms": [],
6
8
  "excludePlatforms": [],
7
9
  "allowUnsafeCode": true,
package/Runtime/AmaGDK.cs CHANGED
@@ -27,7 +27,7 @@ namespace Amanotes.Core
27
27
  {
28
28
  public partial class AmaGDK : MonoBehaviour
29
29
  {
30
- public const string VERSION = "v0.2.81-alpha.8";
30
+ public const string VERSION = "0.2.84";
31
31
 
32
32
  internal static Status _status = Status.None;
33
33
  internal static ConfigAsset _config = null;