com.amanotes.gdk 0.2.19 → 0.2.20
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 +3 -0
- package/Editor/UserProfile.PostBuild.cs.meta +1 -1
- package/Editor/UserProfileDependencies.xml.meta +1 -1
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -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/Packages/IronSourceAdapter_v7.2.6.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v5.3.0.unitypackage +0 -0
- package/Packages/{RevenueCatAdapter_v5.1.3.unitypackage.meta → RevenueCatAdapter_v5.3.0.unitypackage.meta} +1 -1
- package/Runtime/AmaGDK.IAP.cs +125 -30
- package/Runtime/AmaGDK.cs +2 -2
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdFetcher.java.meta +1 -1
- package/Runtime/UserProfile/Plugins/Android.meta +1 -1
- package/package.json +1 -1
- package/Packages/RevenueCatAdapter_v5.1.3.unitypackage +0 -0
package/CHANGELOG.md
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.IAP.cs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections;
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
+
using System.Globalization;
|
|
4
5
|
using UnityEngine;
|
|
5
6
|
using Amanotes.Core.Internal;
|
|
6
7
|
|
|
@@ -14,15 +15,21 @@ namespace Amanotes.Core
|
|
|
14
15
|
public partial class IAP //Public
|
|
15
16
|
{
|
|
16
17
|
public static bool IsVIP => !string.IsNullOrEmpty(localData.activeSubscriptionId);
|
|
17
|
-
|
|
18
18
|
public static string ActiveSubscriptionId => localData.activeSubscriptionId;
|
|
19
|
-
|
|
19
|
+
public static string SubscriptionPeriodType => localData.subscriptionPeriodType;
|
|
20
|
+
public static DateTime? SubscriptionLastPurchaseDate => localData.SubscriptionLastPurchaseDate;
|
|
21
|
+
public static DateTime? SubscriptionExpiredDate => localData.SubscriptionExpiredDate;
|
|
22
|
+
public static DateTime? UnsubscribedDate => localData.UnsubscribedDate;
|
|
20
23
|
public static Dictionary<string, ProductInfo> AllProducts => dicProducts;
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
private const string DATE_FORMAT = "yyyy/MM/yy HH:mm:ss";
|
|
25
|
+
|
|
26
|
+
public static ISetupBuilder GetProducts(bool appendExistingList = false)
|
|
23
27
|
{
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
if (!appendExistingList)
|
|
29
|
+
{
|
|
30
|
+
IAPExtension.isCleanUpConfig = false;
|
|
31
|
+
dicProducts.Clear();
|
|
32
|
+
}
|
|
26
33
|
var result = new SetupContext();
|
|
27
34
|
ExecuteInNextFrame(result.GetProducts);
|
|
28
35
|
return result;
|
|
@@ -31,7 +38,13 @@ namespace Amanotes.Core
|
|
|
31
38
|
public static IPurchaseBuilder Purchase(string productId)
|
|
32
39
|
{
|
|
33
40
|
var result = new PurchaseContext();
|
|
34
|
-
|
|
41
|
+
if (!dicProducts.ContainsKey(productId))
|
|
42
|
+
{
|
|
43
|
+
LogWarning($"[IAP] Product {productId} is not found");
|
|
44
|
+
result.onFail?.Invoke(new PurchaseError($"Product {productId} is not found"));
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
ExecuteInNextFrame(() => result.Purchase(dicProducts[productId]));
|
|
35
48
|
return result;
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -46,7 +59,7 @@ namespace Amanotes.Core
|
|
|
46
59
|
{
|
|
47
60
|
if (!dicProducts.ContainsKey(productId))
|
|
48
61
|
{
|
|
49
|
-
LogWarning($"[IAP] Not found product with id <{productId}>. Make sure you have called
|
|
62
|
+
LogWarning($"[IAP] Not found product with id <{productId}>. Make sure you have called GetProducts() first.");
|
|
50
63
|
return null;
|
|
51
64
|
}
|
|
52
65
|
|
|
@@ -73,6 +86,13 @@ namespace Amanotes.Core
|
|
|
73
86
|
{
|
|
74
87
|
return Adapter?.GetPurchaseHistory();
|
|
75
88
|
}
|
|
89
|
+
|
|
90
|
+
public static DateTime? GetLastPurchaseDate(string productId)
|
|
91
|
+
{
|
|
92
|
+
var product = GetProduct(productId);
|
|
93
|
+
if (product == null) return null;
|
|
94
|
+
return Adapter?.GetLastPurchaseDate(product.productAndPlanId);
|
|
95
|
+
}
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
public partial class IAP //Internal
|
|
@@ -134,12 +154,68 @@ namespace Amanotes.Core
|
|
|
134
154
|
internal class IAPData : IJsonFile
|
|
135
155
|
{
|
|
136
156
|
public string activeSubscriptionId;
|
|
157
|
+
public string subscriptionPeriodType;
|
|
158
|
+
public string subscriptionLastPurchaseDate;
|
|
159
|
+
public string subscriptionExpiredDate;
|
|
160
|
+
public string unsubscribedDate;
|
|
137
161
|
public List<string> purchasedProducts;
|
|
162
|
+
|
|
163
|
+
private DateTime? _subscriptionLastPurchaseDate;
|
|
164
|
+
public DateTime? SubscriptionLastPurchaseDate
|
|
165
|
+
{
|
|
166
|
+
get
|
|
167
|
+
{
|
|
168
|
+
if (_subscriptionLastPurchaseDate != null) return _subscriptionLastPurchaseDate;
|
|
169
|
+
if (DateTime.TryParseExact(subscriptionLastPurchaseDate, DATE_FORMAT,
|
|
170
|
+
CultureInfo.InvariantCulture, DateTimeStyles.None, out var pd))
|
|
171
|
+
{
|
|
172
|
+
_subscriptionLastPurchaseDate = pd;
|
|
173
|
+
}
|
|
174
|
+
return _subscriptionLastPurchaseDate;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private DateTime? _subscriptionExpiredDate;
|
|
179
|
+
public DateTime? SubscriptionExpiredDate
|
|
180
|
+
{
|
|
181
|
+
get
|
|
182
|
+
{
|
|
183
|
+
if (_subscriptionExpiredDate != null) return _subscriptionExpiredDate;
|
|
184
|
+
if (DateTime.TryParseExact(subscriptionExpiredDate, DATE_FORMAT,
|
|
185
|
+
CultureInfo.InvariantCulture, DateTimeStyles.None, out var pd))
|
|
186
|
+
{
|
|
187
|
+
_subscriptionExpiredDate = pd;
|
|
188
|
+
}
|
|
189
|
+
return _subscriptionExpiredDate;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private DateTime? _unsubscribedDate;
|
|
194
|
+
public DateTime? UnsubscribedDate
|
|
195
|
+
{
|
|
196
|
+
get
|
|
197
|
+
{
|
|
198
|
+
if (_unsubscribedDate != null) return _unsubscribedDate;
|
|
199
|
+
if (DateTime.TryParseExact(unsubscribedDate, DATE_FORMAT,
|
|
200
|
+
CultureInfo.InvariantCulture, DateTimeStyles.None, out var pd))
|
|
201
|
+
{
|
|
202
|
+
_unsubscribedDate = pd;
|
|
203
|
+
}
|
|
204
|
+
return _unsubscribedDate;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
138
207
|
|
|
139
208
|
public void Sync()
|
|
140
209
|
{
|
|
141
210
|
activeSubscriptionId = Adapter?.GetActiveSubscriptionId();
|
|
211
|
+
subscriptionPeriodType = Adapter?.GetSubscriptionPeriodType();
|
|
142
212
|
purchasedProducts = Adapter?.GetPurchasedProducts();
|
|
213
|
+
_subscriptionLastPurchaseDate = Adapter?.GetSubscriptionLastPurchaseDate();
|
|
214
|
+
subscriptionLastPurchaseDate = _subscriptionLastPurchaseDate?.ToString(DATE_FORMAT);
|
|
215
|
+
_subscriptionExpiredDate = Adapter?.GetSubscriptionExpiredDate();
|
|
216
|
+
subscriptionExpiredDate = _subscriptionExpiredDate?.ToString(DATE_FORMAT);
|
|
217
|
+
_unsubscribedDate = Adapter?.GetUnsubscribedDate();
|
|
218
|
+
unsubscribedDate = _unsubscribedDate?.ToString(DATE_FORMAT);
|
|
143
219
|
this.SaveJsonToFile();
|
|
144
220
|
}
|
|
145
221
|
}
|
|
@@ -158,6 +234,7 @@ namespace Amanotes.Core
|
|
|
158
234
|
{
|
|
159
235
|
public string id;
|
|
160
236
|
public ProductType type;
|
|
237
|
+
[HideInInspector] public string productAndPlanId;
|
|
161
238
|
[HideInInspector] public string title;
|
|
162
239
|
[HideInInspector] public string description;
|
|
163
240
|
[HideInInspector] public float price;
|
|
@@ -186,8 +263,9 @@ namespace Amanotes.Core
|
|
|
186
263
|
{
|
|
187
264
|
}
|
|
188
265
|
|
|
189
|
-
public PurchaseError(string errorMessage)
|
|
266
|
+
public PurchaseError(string errorMessage, string productId = null)
|
|
190
267
|
{
|
|
268
|
+
this.productId = productId;
|
|
191
269
|
error = errorMessage;
|
|
192
270
|
}
|
|
193
271
|
}
|
|
@@ -241,9 +319,11 @@ namespace Amanotes.Core
|
|
|
241
319
|
{
|
|
242
320
|
if (sc == null) return null;
|
|
243
321
|
ClearOldProductConfig();
|
|
322
|
+
var ls = AdapterConfig?.products;
|
|
323
|
+
if (ls == null) return null;
|
|
244
324
|
foreach (var pId in subs)
|
|
245
325
|
{
|
|
246
|
-
|
|
326
|
+
ls.Add(new ProductInfo { id = pId, type = ProductType.Subscription });
|
|
247
327
|
}
|
|
248
328
|
return sc;
|
|
249
329
|
}
|
|
@@ -252,9 +332,11 @@ namespace Amanotes.Core
|
|
|
252
332
|
{
|
|
253
333
|
if (sc == null) return null;
|
|
254
334
|
ClearOldProductConfig();
|
|
335
|
+
var ls = AdapterConfig?.products;
|
|
336
|
+
if (ls == null) return null;
|
|
255
337
|
foreach (var pId in cons)
|
|
256
338
|
{
|
|
257
|
-
|
|
339
|
+
ls.Add(new ProductInfo { id = pId, type = ProductType.Consumable });
|
|
258
340
|
}
|
|
259
341
|
return sc;
|
|
260
342
|
}
|
|
@@ -263,9 +345,11 @@ namespace Amanotes.Core
|
|
|
263
345
|
{
|
|
264
346
|
if (sc == null) return null;
|
|
265
347
|
ClearOldProductConfig();
|
|
348
|
+
var ls = AdapterConfig?.products;
|
|
349
|
+
if (ls == null) return null;
|
|
266
350
|
foreach (var pId in nons)
|
|
267
351
|
{
|
|
268
|
-
|
|
352
|
+
ls.Add(new ProductInfo { id = pId, type = ProductType.NonConsumable });
|
|
269
353
|
}
|
|
270
354
|
return sc;
|
|
271
355
|
}
|
|
@@ -339,18 +423,29 @@ namespace Amanotes.Core.Internal
|
|
|
339
423
|
|
|
340
424
|
public void GetProducts()
|
|
341
425
|
{
|
|
342
|
-
|
|
426
|
+
var ls = AdapterConfig?.products;
|
|
427
|
+
if (ls == null || ls.Count == 0)
|
|
343
428
|
{
|
|
344
429
|
LogWarning("There is no IAP product");
|
|
345
430
|
return;
|
|
346
|
-
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
#if UNITY_EDITOR
|
|
434
|
+
foreach (var p in ls)
|
|
435
|
+
{
|
|
436
|
+
if (dicProducts.ContainsKey(p.id)) dicProducts[p.id] = p;
|
|
437
|
+
else dicProducts.Add(p.id, p);
|
|
438
|
+
}
|
|
439
|
+
onSuccess?.Invoke(dicProducts);
|
|
440
|
+
return;
|
|
441
|
+
#endif
|
|
347
442
|
|
|
348
443
|
getProdQueue.Clear();
|
|
349
444
|
var subs = new List<string>();
|
|
350
445
|
var cons = new List<string>();
|
|
351
446
|
var nons = new List<string>();
|
|
352
447
|
|
|
353
|
-
foreach (var p in
|
|
448
|
+
foreach (var p in ls)
|
|
354
449
|
{
|
|
355
450
|
switch (p.type)
|
|
356
451
|
{
|
|
@@ -393,9 +488,10 @@ namespace Amanotes.Core.Internal
|
|
|
393
488
|
{
|
|
394
489
|
AmaGDK.IAP.Adapter?.GetProducts(lsProduct.ToArray(), type, (pList) =>
|
|
395
490
|
{
|
|
396
|
-
foreach (var
|
|
491
|
+
foreach (var p in pList)
|
|
397
492
|
{
|
|
398
|
-
dicProducts.
|
|
493
|
+
if (dicProducts.ContainsKey(p.id)) dicProducts[p.id] = p;
|
|
494
|
+
else dicProducts.Add(p.id, p);
|
|
399
495
|
}
|
|
400
496
|
ExecuteInNextFrame(GetNextProductsInQueue);
|
|
401
497
|
}, error => onFail?.Invoke(error));
|
|
@@ -416,20 +512,14 @@ namespace Amanotes.Core.Internal
|
|
|
416
512
|
public Action<PurchaseError> onFail;
|
|
417
513
|
public string discountId;
|
|
418
514
|
|
|
419
|
-
public void Purchase(
|
|
515
|
+
public void Purchase(ProductInfo productInfo)
|
|
420
516
|
{
|
|
421
|
-
if (!dicProducts.ContainsKey(productId))
|
|
422
|
-
{
|
|
423
|
-
LogWarning($"[IAP] Product {productId} is not found");
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
517
|
#if UNITY_EDITOR
|
|
428
518
|
if (AdapterConfig.allPurchaseSuccessInEditor)
|
|
429
519
|
{
|
|
430
520
|
DoOnSuccess(new PurchaseSuccess
|
|
431
521
|
{
|
|
432
|
-
productIds = new[] {
|
|
522
|
+
productIds = new[] { productInfo.id },
|
|
433
523
|
isSandbox = true
|
|
434
524
|
});
|
|
435
525
|
return;
|
|
@@ -438,11 +528,11 @@ namespace Amanotes.Core.Internal
|
|
|
438
528
|
|
|
439
529
|
if (!string.IsNullOrWhiteSpace(discountId))
|
|
440
530
|
{
|
|
441
|
-
AmaGDK.IAP.Adapter?.PurchaseDiscount(
|
|
531
|
+
AmaGDK.IAP.Adapter?.PurchaseDiscount(productInfo, discountId, DoOnSuccess, DoOnFail);
|
|
442
532
|
return;
|
|
443
533
|
}
|
|
444
534
|
|
|
445
|
-
AmaGDK.IAP.Adapter?.Purchase(
|
|
535
|
+
AmaGDK.IAP.Adapter?.Purchase(productInfo, DoOnSuccess, DoOnFail);
|
|
446
536
|
}
|
|
447
537
|
|
|
448
538
|
public void RestorePurchase()
|
|
@@ -465,12 +555,17 @@ namespace Amanotes.Core.Internal
|
|
|
465
555
|
public interface IIAPAdapter
|
|
466
556
|
{
|
|
467
557
|
void GetProducts(string[] productIds, ProductType productType, Action<ProductInfo[]> onSuccess = null, Action<string> onFail = null);
|
|
468
|
-
void Purchase(
|
|
469
|
-
void PurchaseDiscount(
|
|
558
|
+
void Purchase(ProductInfo productInfo, Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
559
|
+
void PurchaseDiscount(ProductInfo productInfo, string discountId, Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
470
560
|
void RestorePurchase(Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
471
561
|
List<string> GetActiveSubscriptions();
|
|
472
562
|
List<string> GetPurchasedProducts();
|
|
473
563
|
string GetActiveSubscriptionId();
|
|
564
|
+
string GetSubscriptionPeriodType();
|
|
565
|
+
DateTime? GetSubscriptionLastPurchaseDate();
|
|
566
|
+
DateTime? GetSubscriptionExpiredDate();
|
|
567
|
+
DateTime? GetUnsubscribedDate();
|
|
474
568
|
HashSet<PurchaseRecord> GetPurchaseHistory();
|
|
569
|
+
DateTime? GetLastPurchaseDate(string productAndPlanId);
|
|
475
570
|
}
|
|
476
|
-
}
|
|
571
|
+
}
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -14,7 +14,7 @@ namespace Amanotes.Core
|
|
|
14
14
|
{
|
|
15
15
|
public partial class AmaGDK : MonoBehaviour
|
|
16
16
|
{
|
|
17
|
-
public const string VERSION = "0.2.
|
|
17
|
+
public const string VERSION = "0.2.20";
|
|
18
18
|
|
|
19
19
|
internal static AmaGDK _instance;
|
|
20
20
|
internal static Status _status = Status.None;
|
|
@@ -62,7 +62,7 @@ namespace Amanotes.Core
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
float time = 0;
|
|
65
|
-
float timeout =
|
|
65
|
+
float timeout = 10;
|
|
66
66
|
|
|
67
67
|
var counter = 0;
|
|
68
68
|
const int INIT_TOLERANCE = 10 * 60;
|
package/package.json
CHANGED
|
Binary file
|