com.amanotes.gdk 0.2.17 → 0.2.18
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 +5 -1
- package/Editor/UserProfile.PostBuild.cs +72 -0
- package/{Runtime/AmaGDK.AmaPassport.cs.meta → Editor/UserProfile.PostBuild.cs.meta} +1 -1
- package/Editor/UserProfileDependencies.xml +5 -0
- package/Editor/UserProfileDependencies.xml.meta +7 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage.meta +0 -1
- 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.1.3.unitypackage +0 -0
- package/Packages/{AmaPassport.ATTSupport.unitypackage.meta → RevenueCatAdapter_v5.1.3.unitypackage.meta} +1 -1
- package/Runtime/AmaGDK.IAP.cs +83 -30
- package/Runtime/AmaGDK.UserProfile.cs +95 -2
- package/Runtime/AmaGDK.cs +2 -2
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdCallback.java +7 -0
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdCallback.java.meta +32 -0
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdFetcher.cs +57 -0
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdFetcher.cs.meta +11 -0
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdFetcher.java +79 -0
- package/Runtime/UserProfile/Plugins/Android/AdvertisingIdFetcher.java.meta +32 -0
- package/Runtime/UserProfile/Plugins/Android.meta +8 -0
- package/Runtime/UserProfile/Plugins/iOS/KeyChain.cs +53 -0
- package/Runtime/UserProfile/Plugins/iOS/KeyChain.cs.meta +11 -0
- package/Runtime/UserProfile/Plugins/iOS/KeyChainPlugin.mm +52 -0
- package/Runtime/UserProfile/Plugins/iOS/KeyChainPlugin.mm.meta +33 -0
- package/Runtime/UserProfile/Plugins/iOS/UICKeyChainStore.h +281 -0
- package/Runtime/UserProfile/Plugins/iOS/UICKeyChainStore.h.meta +33 -0
- package/Runtime/UserProfile/Plugins/iOS/UICKeyChainStore.m +1393 -0
- package/Runtime/UserProfile/Plugins/iOS/UICKeyChainStore.m.meta +33 -0
- package/Runtime/UserProfile/Plugins/iOS.meta +8 -0
- package/Runtime/UserProfile/Plugins.meta +8 -0
- package/{Packages/AmaPassportAdapter_v1.0.0.unitypackage.meta → Runtime/UserProfile.meta} +2 -1
- package/package.json +1 -1
- package/Packages/AmaPassport.ATTSupport.unitypackage +0 -0
- package/Packages/AmaPassportAdapter_v1.0.0.unitypackage +0 -0
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
- package/Runtime/AmaGDK.AmaPassport.cs +0 -440
- /package/Packages/{IronsourceAdapter_v7.2.6.unitypackage.meta → IronSourceAdapter_v7.2.6.unitypackage.meta} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.2.
|
|
3
|
+
## [0.2.18 - 2023-09-11]
|
|
4
|
+
### Add dev mode switch
|
|
5
|
+
### Auto get SDK version
|
|
6
|
+
### Add in-app purchase module, RevenueCat
|
|
4
7
|
### Support Unity 2019.4
|
|
8
|
+
### Remove AmaPassport
|
|
5
9
|
|
|
6
10
|
## [0.2.14 - 2023-08-08]
|
|
7
11
|
### Support multiple embed remote config and load config by id
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
#if UNITY_EDITOR && UNITY_IOS
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEditor.Callbacks;
|
|
8
|
+
using UnityEditor.iOS.Xcode;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
#if UNITY_IOS
|
|
12
|
+
namespace Amanotes.Core
|
|
13
|
+
{
|
|
14
|
+
internal static class UserProfilePostBuild
|
|
15
|
+
{
|
|
16
|
+
[PostProcessBuild(10000)]
|
|
17
|
+
public static void PostBuild(BuildTarget buildTarget, string pathToBuiltProject)
|
|
18
|
+
{
|
|
19
|
+
if (buildTarget != BuildTarget.iOS) return;
|
|
20
|
+
var entitlementFilePath = VerifyEntitlements(pathToBuiltProject);
|
|
21
|
+
AddKeychainSharing(pathToBuiltProject, entitlementFilePath);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static string VerifyEntitlements(string pathToBuiltProject)
|
|
25
|
+
{
|
|
26
|
+
Debug.Log("UserProfilePostBuild: VerifyEntitlements");
|
|
27
|
+
|
|
28
|
+
var projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
|
|
29
|
+
var proj = new PBXProject();
|
|
30
|
+
proj.ReadFromString(File.ReadAllText(projPath));
|
|
31
|
+
|
|
32
|
+
#if UNITY_2019_3_OR_NEWER
|
|
33
|
+
var appTargetId = proj.GetUnityMainTargetGuid();
|
|
34
|
+
var frameworkTargetId = proj.GetUnityFrameworkTargetGuid();
|
|
35
|
+
#else
|
|
36
|
+
string targetName = PBXProject.GetUnityTargetName();
|
|
37
|
+
string appTargetId = proj.TargetGuidByName(targetName);
|
|
38
|
+
string frameworkTargetId = appTargetId; //No UnityFramework target, get main target instead
|
|
39
|
+
#endif
|
|
40
|
+
//Check present of entitlements
|
|
41
|
+
var localPath = proj.GetBuildPropertyForAnyConfig(appTargetId, "CODE_SIGN_ENTITLEMENTS") ?? "Entitlements.entitlements";
|
|
42
|
+
var fullPath = $"{pathToBuiltProject}/{localPath}";
|
|
43
|
+
|
|
44
|
+
//Entitlements.entitlements
|
|
45
|
+
//Missing entitlement dismiss the auto enable Keychain Sharing
|
|
46
|
+
if (!File.Exists(fullPath))
|
|
47
|
+
{
|
|
48
|
+
const string txtEntitlement = @"<?xml version=""1.0"" encoding=""UTF-8""?>
|
|
49
|
+
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
|
|
50
|
+
<plist version = ""1.0"">
|
|
51
|
+
<dict>
|
|
52
|
+
</dict>
|
|
53
|
+
</plist>";
|
|
54
|
+
File.WriteAllText(fullPath, txtEntitlement);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
proj.AddFileToBuild(appTargetId, proj.AddFile(fullPath, localPath));
|
|
58
|
+
proj.SetBuildProperty(appTargetId, "CODE_SIGN_ENTITLEMENTS", localPath);
|
|
59
|
+
return localPath;
|
|
60
|
+
}
|
|
61
|
+
public static void AddKeychainSharing(string pathToBuiltProject, string entitlementsLocalPath)
|
|
62
|
+
{
|
|
63
|
+
Debug.Log("UserProfilePostBuild: AddKeychainSharing");
|
|
64
|
+
var projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
|
|
65
|
+
var capabilityManager = new ProjectCapabilityManager(projPath, entitlementsLocalPath, "Unity-iPhone");
|
|
66
|
+
capabilityManager.AddKeychainSharing(new string[] { "$(AppIdentifierPrefix)com.amanotes.shared" });
|
|
67
|
+
capabilityManager.WriteToFile();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#endif
|
|
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
|
@@ -21,6 +21,8 @@ namespace Amanotes.Core
|
|
|
21
21
|
|
|
22
22
|
public static ISetupBuilder GetProducts()
|
|
23
23
|
{
|
|
24
|
+
IAPExtension.isCleanUpConfig = false;
|
|
25
|
+
dicProducts.Clear();
|
|
24
26
|
var result = new SetupContext();
|
|
25
27
|
ExecuteInNextFrame(result.GetProducts);
|
|
26
28
|
return result;
|
|
@@ -53,7 +55,7 @@ namespace Amanotes.Core
|
|
|
53
55
|
|
|
54
56
|
public static List<string> GetActiveSubscriptions()
|
|
55
57
|
{
|
|
56
|
-
return
|
|
58
|
+
return Adapter?.GetActiveSubscriptions();
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
public static List<string> GetPurchasedProductIds()
|
|
@@ -66,17 +68,22 @@ namespace Amanotes.Core
|
|
|
66
68
|
var purchasedProductIds = GetPurchasedProductIds();
|
|
67
69
|
return purchasedProductIds != null && purchasedProductIds.Contains(productId);
|
|
68
70
|
}
|
|
71
|
+
|
|
72
|
+
public static HashSet<PurchaseRecord> GetPurchaseHistory()
|
|
73
|
+
{
|
|
74
|
+
return Adapter?.GetPurchaseHistory();
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
public partial class IAP //Internal
|
|
72
79
|
{
|
|
73
|
-
|
|
80
|
+
private static IIAPAdapter _adapter;
|
|
74
81
|
internal static readonly IAPData localData = new IAPData().LoadJsonFromFile();
|
|
75
|
-
internal static IIAPAdapter
|
|
82
|
+
internal static IIAPAdapter Adapter
|
|
76
83
|
{
|
|
77
84
|
get
|
|
78
85
|
{
|
|
79
|
-
if (
|
|
86
|
+
if (_adapter != null) return _adapter;
|
|
80
87
|
LogWarning("[IAP] Adapter is not available.");
|
|
81
88
|
return null;
|
|
82
89
|
}
|
|
@@ -97,11 +104,11 @@ namespace Amanotes.Core
|
|
|
97
104
|
|
|
98
105
|
internal static void Init()
|
|
99
106
|
{
|
|
100
|
-
|
|
101
|
-
var adapterContext =
|
|
107
|
+
_adapter = Internal.Adapter.GetSingleAdapter<IIAPAdapter>();
|
|
108
|
+
var adapterContext = _adapter as AdapterContext;
|
|
102
109
|
|
|
103
110
|
if (adapterContext == null) return;
|
|
104
|
-
_adapterConfig = adapterContext
|
|
111
|
+
_adapterConfig = adapterContext.GetAdapterConfig<IAPAdapterConfig>();
|
|
105
112
|
|
|
106
113
|
if (!adapterContext.IsReady) return;
|
|
107
114
|
localData.Sync();
|
|
@@ -131,8 +138,8 @@ namespace Amanotes.Core
|
|
|
131
138
|
|
|
132
139
|
public void Sync()
|
|
133
140
|
{
|
|
134
|
-
activeSubscriptionId =
|
|
135
|
-
purchasedProducts =
|
|
141
|
+
activeSubscriptionId = Adapter?.GetActiveSubscriptionId();
|
|
142
|
+
purchasedProducts = Adapter?.GetPurchasedProducts();
|
|
136
143
|
this.SaveJsonToFile();
|
|
137
144
|
}
|
|
138
145
|
}
|
|
@@ -155,15 +162,18 @@ namespace Amanotes.Core
|
|
|
155
162
|
[HideInInspector] public string description;
|
|
156
163
|
[HideInInspector] public float price;
|
|
157
164
|
[HideInInspector] public string currencyCode;
|
|
165
|
+
[HideInInspector] public string priceString;
|
|
166
|
+
[HideInInspector] public string introPriceString;
|
|
167
|
+
[HideInInspector] public string introPricePeriod;
|
|
168
|
+
[HideInInspector] public int introPricePeriodNumberOfUnits;
|
|
169
|
+
[HideInInspector] public string introPricePeriodUnit;
|
|
158
170
|
[HideInInspector] public string[] discountIds;
|
|
159
171
|
}
|
|
160
172
|
|
|
161
173
|
public class PurchaseSuccess
|
|
162
174
|
{
|
|
163
|
-
public string
|
|
164
|
-
public
|
|
165
|
-
public string receipt;
|
|
166
|
-
public string purchaseToken;
|
|
175
|
+
public string[] productIds;
|
|
176
|
+
public bool isSandbox;
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
public class PurchaseError
|
|
@@ -182,16 +192,58 @@ namespace Amanotes.Core
|
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
|
|
195
|
+
public class PurchaseRecord
|
|
196
|
+
{
|
|
197
|
+
public string productId;
|
|
198
|
+
public DateTime purchaseDate;
|
|
199
|
+
|
|
200
|
+
public PurchaseRecord(string productId, DateTime purchaseDate)
|
|
201
|
+
{
|
|
202
|
+
this.productId = productId;
|
|
203
|
+
this.purchaseDate = purchaseDate;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public class PurchaseRecordEqualityComparer : IEqualityComparer<PurchaseRecord>
|
|
208
|
+
{
|
|
209
|
+
public bool Equals(PurchaseRecord x, PurchaseRecord y)
|
|
210
|
+
{
|
|
211
|
+
if (ReferenceEquals(x, y)) return true;
|
|
212
|
+
if (ReferenceEquals(x, null) || ReferenceEquals(y, null)) return false;
|
|
213
|
+
return x.productId == y.productId &&
|
|
214
|
+
x.purchaseDate == y.purchaseDate;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public int GetHashCode(PurchaseRecord obj)
|
|
218
|
+
{
|
|
219
|
+
unchecked
|
|
220
|
+
{
|
|
221
|
+
int hashCode = obj.productId != null ? obj.productId.GetHashCode() : 0;
|
|
222
|
+
hashCode = (hashCode * 397) ^ obj.purchaseDate.GetHashCode();
|
|
223
|
+
return hashCode;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
185
228
|
public static class IAPExtension
|
|
186
229
|
{
|
|
187
230
|
//GetProducts extensions
|
|
231
|
+
internal static bool isCleanUpConfig;
|
|
232
|
+
|
|
233
|
+
internal static void ClearOldProductConfig()
|
|
234
|
+
{
|
|
235
|
+
if (isCleanUpConfig) return;
|
|
236
|
+
AdapterConfig?.products.Clear();
|
|
237
|
+
isCleanUpConfig = true;
|
|
238
|
+
}
|
|
239
|
+
|
|
188
240
|
public static ISetupBuilder SetSubscriptions(this ISetupBuilder sc, params string[] subs)
|
|
189
241
|
{
|
|
190
242
|
if (sc == null) return null;
|
|
191
|
-
|
|
243
|
+
ClearOldProductConfig();
|
|
192
244
|
foreach (var pId in subs)
|
|
193
245
|
{
|
|
194
|
-
AdapterConfig?.products.Add(new ProductInfo
|
|
246
|
+
AdapterConfig?.products.Add(new ProductInfo { id = pId, type = ProductType.Subscription });
|
|
195
247
|
}
|
|
196
248
|
return sc;
|
|
197
249
|
}
|
|
@@ -199,10 +251,10 @@ namespace Amanotes.Core
|
|
|
199
251
|
public static ISetupBuilder SetConsumables(this ISetupBuilder sc, params string[] cons)
|
|
200
252
|
{
|
|
201
253
|
if (sc == null) return null;
|
|
202
|
-
|
|
254
|
+
ClearOldProductConfig();
|
|
203
255
|
foreach (var pId in cons)
|
|
204
256
|
{
|
|
205
|
-
AdapterConfig?.products.Add(new ProductInfo
|
|
257
|
+
AdapterConfig?.products.Add(new ProductInfo { id = pId, type = ProductType.Consumable });
|
|
206
258
|
}
|
|
207
259
|
return sc;
|
|
208
260
|
}
|
|
@@ -210,10 +262,10 @@ namespace Amanotes.Core
|
|
|
210
262
|
public static ISetupBuilder SetNonComsumables(this ISetupBuilder sc, params string[] nons)
|
|
211
263
|
{
|
|
212
264
|
if (sc == null) return null;
|
|
213
|
-
|
|
265
|
+
ClearOldProductConfig();
|
|
214
266
|
foreach (var pId in nons)
|
|
215
267
|
{
|
|
216
|
-
AdapterConfig?.products.Add(new ProductInfo
|
|
268
|
+
AdapterConfig?.products.Add(new ProductInfo { id = pId, type = ProductType.NonConsumable });
|
|
217
269
|
}
|
|
218
270
|
return sc;
|
|
219
271
|
}
|
|
@@ -339,20 +391,19 @@ namespace Amanotes.Core.Internal
|
|
|
339
391
|
{
|
|
340
392
|
try
|
|
341
393
|
{
|
|
342
|
-
|
|
394
|
+
AmaGDK.IAP.Adapter?.GetProducts(lsProduct.ToArray(), type, (pList) =>
|
|
343
395
|
{
|
|
344
396
|
foreach (var pI in pList)
|
|
345
397
|
{
|
|
346
398
|
dicProducts.Add(pI.id, pI);
|
|
347
399
|
}
|
|
348
400
|
ExecuteInNextFrame(GetNextProductsInQueue);
|
|
349
|
-
});
|
|
401
|
+
}, error => onFail?.Invoke(error));
|
|
350
402
|
}
|
|
351
403
|
catch (Exception e)
|
|
352
404
|
{
|
|
353
405
|
LogWarning($"[IAP] Error on getting products of type <{type}>. Error detail:\n{e.Message}");
|
|
354
406
|
onFail?.Invoke(e.Message);
|
|
355
|
-
throw;
|
|
356
407
|
}
|
|
357
408
|
}
|
|
358
409
|
}
|
|
@@ -378,7 +429,8 @@ namespace Amanotes.Core.Internal
|
|
|
378
429
|
{
|
|
379
430
|
DoOnSuccess(new PurchaseSuccess
|
|
380
431
|
{
|
|
381
|
-
|
|
432
|
+
productIds = new[] { productId },
|
|
433
|
+
isSandbox = true
|
|
382
434
|
});
|
|
383
435
|
return;
|
|
384
436
|
}
|
|
@@ -386,16 +438,16 @@ namespace Amanotes.Core.Internal
|
|
|
386
438
|
|
|
387
439
|
if (!string.IsNullOrWhiteSpace(discountId))
|
|
388
440
|
{
|
|
389
|
-
|
|
441
|
+
AmaGDK.IAP.Adapter?.PurchaseDiscount(productId, dicProducts[productId].type, discountId, DoOnSuccess, DoOnFail);
|
|
390
442
|
return;
|
|
391
443
|
}
|
|
392
444
|
|
|
393
|
-
|
|
445
|
+
AmaGDK.IAP.Adapter?.Purchase(productId, dicProducts[productId].type, DoOnSuccess, DoOnFail);
|
|
394
446
|
}
|
|
395
447
|
|
|
396
448
|
public void RestorePurchase()
|
|
397
449
|
{
|
|
398
|
-
|
|
450
|
+
AmaGDK.IAP.Adapter?.RestorePurchase(DoOnSuccess, DoOnFail);
|
|
399
451
|
}
|
|
400
452
|
|
|
401
453
|
void DoOnSuccess(PurchaseSuccess success)
|
|
@@ -412,12 +464,13 @@ namespace Amanotes.Core.Internal
|
|
|
412
464
|
|
|
413
465
|
public interface IIAPAdapter
|
|
414
466
|
{
|
|
415
|
-
void GetProducts(string[] productIds, ProductType productType, Action<ProductInfo[]>
|
|
416
|
-
void Purchase(string productId, ProductType productType, Action<PurchaseSuccess> onSuccess, Action<PurchaseError> onFail);
|
|
417
|
-
void PurchaseDiscount(string productId, ProductType productType, string discountId, Action<PurchaseSuccess> onSuccess, Action<PurchaseError> onFail);
|
|
418
|
-
void RestorePurchase(Action<PurchaseSuccess> onSuccess, Action<PurchaseError> onFail);
|
|
467
|
+
void GetProducts(string[] productIds, ProductType productType, Action<ProductInfo[]> onSuccess = null, Action<string> onFail = null);
|
|
468
|
+
void Purchase(string productId, ProductType productType, Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
469
|
+
void PurchaseDiscount(string productId, ProductType productType, string discountId, Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
470
|
+
void RestorePurchase(Action<PurchaseSuccess> onSuccess = null, Action<PurchaseError> onFail = null);
|
|
419
471
|
List<string> GetActiveSubscriptions();
|
|
420
472
|
List<string> GetPurchasedProducts();
|
|
421
473
|
string GetActiveSubscriptionId();
|
|
474
|
+
HashSet<PurchaseRecord> GetPurchaseHistory();
|
|
422
475
|
}
|
|
423
476
|
}
|
|
@@ -13,12 +13,12 @@ namespace Amanotes.Core
|
|
|
13
13
|
private const string FILE_NAME = nameof(UserProfile);
|
|
14
14
|
[NonSerialized] internal bool _dirty;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
private void Save()
|
|
17
17
|
{
|
|
18
18
|
GDKFileUtils.Save(FILE_NAME, JsonUtility.ToJson(this));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
internal UserProfile Load()
|
|
22
22
|
{
|
|
23
23
|
string json = GDKFileUtils.Load(FILE_NAME);
|
|
24
24
|
if (string.IsNullOrEmpty(json)) return this;
|
|
@@ -33,5 +33,98 @@ namespace Amanotes.Core
|
|
|
33
33
|
this.SaveJsonToFile();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
public partial class UserProfile
|
|
38
|
+
{
|
|
39
|
+
public string GAId => gaid;
|
|
40
|
+
public string IDFA => idfa;
|
|
41
|
+
public string IDFV => idfv;
|
|
42
|
+
public string AndroidId => androidId;
|
|
43
|
+
public string AmaDeviceId => amaDeviceId;
|
|
44
|
+
public string AppsFlyerId => appsFlyerId;
|
|
45
|
+
|
|
46
|
+
[SerializeField]
|
|
47
|
+
private string gaid;
|
|
48
|
+
[SerializeField]
|
|
49
|
+
private string idfa;
|
|
50
|
+
[SerializeField]
|
|
51
|
+
private string idfv;
|
|
52
|
+
[SerializeField]
|
|
53
|
+
private string androidId;
|
|
54
|
+
[SerializeField]
|
|
55
|
+
private string amaDeviceId;
|
|
56
|
+
[SerializeField]
|
|
57
|
+
private string appsFlyerId;
|
|
58
|
+
|
|
59
|
+
private const string AMA_DEVICE_ID_KEY = "ama_device_id";
|
|
60
|
+
|
|
61
|
+
internal void InitUserProfile()
|
|
62
|
+
{
|
|
63
|
+
if (!IsAmaDeviceIdExist()) GetAdvertisingId();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private bool IsAmaDeviceIdExist()
|
|
67
|
+
{
|
|
68
|
+
if (!string.IsNullOrEmpty(amaDeviceId))
|
|
69
|
+
{
|
|
70
|
+
Logging.Log($"AmaDeviceId is already exist: {amaDeviceId}");
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private void SetAdvertisingID(string id)
|
|
77
|
+
{
|
|
78
|
+
switch (Application.platform)
|
|
79
|
+
{
|
|
80
|
+
case RuntimePlatform.IPhonePlayer:
|
|
81
|
+
idfa = id;
|
|
82
|
+
idfv = SystemInfo.deviceUniqueIdentifier;
|
|
83
|
+
break;
|
|
84
|
+
case RuntimePlatform.Android:
|
|
85
|
+
gaid = id;
|
|
86
|
+
androidId = SystemInfo.deviceUniqueIdentifier;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
Logging.LogWarning($"Unsupported platform: {Application.platform}");
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
private void GetAdvertisingId()
|
|
94
|
+
{
|
|
95
|
+
AdvertisingIdFetcher.RequestAdvertisingId(advertisingId =>
|
|
96
|
+
{
|
|
97
|
+
SetAdvertisingID(advertisingId);
|
|
98
|
+
switch (Application.platform)
|
|
99
|
+
{
|
|
100
|
+
case RuntimePlatform.IPhonePlayer:
|
|
101
|
+
string v = KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY);
|
|
102
|
+
if (string.IsNullOrEmpty(v))
|
|
103
|
+
{
|
|
104
|
+
v = Guid.NewGuid().ToString();
|
|
105
|
+
KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, v);
|
|
106
|
+
}
|
|
107
|
+
amaDeviceId = v;
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case RuntimePlatform.Android:
|
|
111
|
+
string _amaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
|
|
112
|
+
if (string.IsNullOrEmpty(amaDeviceId))
|
|
113
|
+
{
|
|
114
|
+
_amaDeviceId = SystemInfo.deviceUniqueIdentifier;
|
|
115
|
+
PlayerPrefs.SetString(AMA_DEVICE_ID_KEY, amaDeviceId);
|
|
116
|
+
}
|
|
117
|
+
amaDeviceId = _amaDeviceId;
|
|
118
|
+
break;
|
|
119
|
+
|
|
120
|
+
default:
|
|
121
|
+
Logging.LogWarning($"Not support ama_device_id on: {Application.platform}");
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
Logging.Log($"Generate AmaDeviceId completed: {amaDeviceId}");
|
|
125
|
+
User.Save();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
36
129
|
}
|
|
37
130
|
}
|
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.18";
|
|
18
18
|
|
|
19
19
|
internal static AmaGDK _instance;
|
|
20
20
|
internal static Status _status = Status.None;
|
|
@@ -106,7 +106,7 @@ namespace Amanotes.Core
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Init modules (Adapter managers)
|
|
109
|
-
|
|
109
|
+
User.InitUserProfile();
|
|
110
110
|
Analytics.Init();
|
|
111
111
|
Ads.Init();
|
|
112
112
|
IAP.Init();
|
|
@@ -0,0 +1,32 @@
|
|
|
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:
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using static Amanotes.Core.Internal.Logging;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
internal class AdvertisingIdFetcher
|
|
8
|
+
{
|
|
9
|
+
public static void RequestAdvertisingId(Action<string> callback)
|
|
10
|
+
{
|
|
11
|
+
new AdvertisingIdFetcher().DoRequestAdvertisingId(callback);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private Action<string> mCallback;
|
|
15
|
+
|
|
16
|
+
private void DoRequestAdvertisingId(Action<string> callback)
|
|
17
|
+
{
|
|
18
|
+
mCallback = callback;
|
|
19
|
+
|
|
20
|
+
#if UNITY_EDITOR
|
|
21
|
+
OnAdvertisingIdReceived("0000-0000-0000-0000");
|
|
22
|
+
#elif UNITY_ANDROID && UNITY_2020_1_OR_NEWER
|
|
23
|
+
var fetcher = new AndroidJavaObject("com.miniit.android.AdvertisingIdFetcher");
|
|
24
|
+
fetcher.Call("requestAdvertisingId", new AdvertisingIdPluginCallback(OnAdvertisingIdReceived));
|
|
25
|
+
#else
|
|
26
|
+
Application.RequestAdvertisingIdentifierAsync(OnAdvertisingIdReceived);
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private void OnAdvertisingIdReceived(string advertisingId)
|
|
31
|
+
{
|
|
32
|
+
mCallback?.Invoke(advertisingId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private void OnAdvertisingIdReceived(string advertisingId, bool trackingEnabled, string errorMsg)
|
|
36
|
+
{
|
|
37
|
+
mCallback?.Invoke(advertisingId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#if UNITY_ANDROID && UNITY_2020_1_OR_NEWER
|
|
42
|
+
public class AdvertisingIdPluginCallback : AndroidJavaProxy
|
|
43
|
+
{
|
|
44
|
+
private Action<string> mCallback;
|
|
45
|
+
|
|
46
|
+
public AdvertisingIdPluginCallback(Action<string> callback) : base("com.miniit.android.AdvertisingIdCallback")
|
|
47
|
+
{
|
|
48
|
+
mCallback = callback;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void onResult(string adid)
|
|
52
|
+
{
|
|
53
|
+
mCallback?.Invoke(adid);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
#endif
|
|
57
|
+
}
|