com.amanotes.gdk 0.2.78 → 0.2.79-2

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.79-2] - 2024-12-03
4
+ - [Fix] IAP data sync with RevenueCat's customer info
5
+ - [Fix] Do not set user of RevenueCat
6
+
7
+ ## [0.2.79] - 2024-11-13
8
+ - [Dev] Add callbacks for IAP module
9
+ - [Fix] Return empty collections instead of null in RevenueCatAdapter
10
+ - [GameOps] Remove durationInSecs
11
+
3
12
  ## [0.2.78] - 2024-11-11
4
13
  - [Dev] Add iOS and Android ad unit configuration for MAX
5
14
  - [Dev] Track Adapters and Third-party packages used in games
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -23,6 +23,67 @@ namespace Amanotes.Core
23
23
  public static readonly Dictionary<string, ProductInfo> AllProducts = new Dictionary<string, ProductInfo>();
24
24
  private const string DATE_FORMAT = "yyyy/MM/yy HH:mm:ss";
25
25
 
26
+ public static void SetCallback_OnModuleReady(Action onReady)
27
+ {
28
+ if (onReady == null) return;
29
+
30
+ if (IsModuleReady)
31
+ {
32
+ onReady();
33
+ return;
34
+ }
35
+
36
+ _onModuleReady -= onReady;
37
+ _onModuleReady += onReady;
38
+ }
39
+
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
+ public static void SyncCustomerInfo(Action<bool> onComplete = null)
69
+ {
70
+ if (_adapter == null)
71
+ {
72
+ onComplete?.Invoke(false);
73
+ return;
74
+ }
75
+ _adapter.SyncCustomerInfo(success =>
76
+ {
77
+ if (!success)
78
+ {
79
+ onComplete?.Invoke(false);
80
+ return;
81
+ }
82
+ localData.Sync();
83
+ onComplete?.Invoke(true);
84
+ });
85
+ }
86
+
26
87
  public static ISetupBuilder GetProducts(bool appendExistingList = false)
27
88
  {
28
89
  if (!appendExistingList)
@@ -129,6 +190,13 @@ namespace Amanotes.Core
129
190
  }
130
191
  }
131
192
 
193
+ private static bool isGetProductComplete;
194
+ private static bool isGetCustomerInfoComplete;
195
+ private static bool IsModuleReady => isGetProductComplete && isGetCustomerInfoComplete;
196
+ private static Action _onGetProductsComplete;
197
+ private static Action _onGetCustomerInfoComplete;
198
+ private static Action _onModuleReady;
199
+
132
200
  internal static bool InitModule()
133
201
  {
134
202
  _adapter = Adapter2.GetAdapter<IAPAdapter>();
@@ -140,8 +208,30 @@ namespace Amanotes.Core
140
208
  internal static void StartModule()
141
209
  {
142
210
  if (_adapter == null) return;
143
- localData.Sync();
144
- if (Config.iap.autoGetProducts) GetProducts();
211
+ SyncCustomerInfo(
212
+ success =>
213
+ {
214
+ isGetCustomerInfoComplete = true;
215
+ GDKUtils.SafeInvokeAndClear(ref _onGetCustomerInfoComplete);
216
+ if (IsModuleReady) GDKUtils.SafeInvokeAndClear(ref _onModuleReady);
217
+ });
218
+ if (Config.iap.autoGetProducts)
219
+ {
220
+ GetProducts()
221
+ .OnSuccess(_ => OnGetProductsComplete())
222
+ .OnFail(_ => OnGetProductsComplete());
223
+ }
224
+ else
225
+ {
226
+ OnGetProductsComplete();
227
+ }
228
+ }
229
+
230
+ private static void OnGetProductsComplete()
231
+ {
232
+ isGetProductComplete = true;
233
+ GDKUtils.SafeInvokeAndClear(ref _onGetProductsComplete);
234
+ if (IsModuleReady) GDKUtils.SafeInvokeAndClear(ref _onModuleReady);
145
235
  }
146
236
  }
147
237
 
@@ -442,6 +532,7 @@ namespace Amanotes.Core.Internal
442
532
  if (ls == null || ls.Count == 0)
443
533
  {
444
534
  LogWarning("There is no IAP product");
535
+ onSuccess?.Invoke(AllProducts);
445
536
  return;
446
537
  }
447
538
 
@@ -506,8 +597,7 @@ namespace Amanotes.Core.Internal
506
597
  {
507
598
  foreach (var p in pList)
508
599
  {
509
- if (AllProducts.ContainsKey(p.id)) AllProducts[p.id] = p;
510
- else AllProducts.Add(p.id, p);
600
+ AllProducts[p.id] = p;
511
601
  }
512
602
  GDKUtils.DelayCall(0f, GetNextProductsInQueue);
513
603
  }, error => onFail?.Invoke(error));
@@ -573,5 +663,7 @@ namespace Amanotes.Core.Internal
573
663
  public abstract DateTime? GetUnsubscribedDate();
574
664
  public abstract HashSet<PurchaseRecord> GetPurchaseHistory();
575
665
  public abstract DateTime? GetLastPurchaseDate(string productAndPlanId);
666
+
667
+ public abstract void SyncCustomerInfo(Action<bool> onComplete = null);
576
668
  }
577
669
  }
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 = "0.2.78";
30
+ public const string VERSION = "0.2.79-2";
31
31
 
32
32
  internal static Status _status = Status.None;
33
33
  private static ConfigAsset _config = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.78",
3
+ "version": "0.2.79-2",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",