com.amanotes.gdk 0.2.81-alpha.8 → 0.2.82-alpha.1
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 -0
- package/Editor/Extra/SDKVersionTracking.cs +9 -1
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.Max.cs +113 -0
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.Max.cs.meta +3 -0
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +8 -10
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AutoEventQC.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- package/Extra/CrashlyticHook.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AdLogic.cs +44 -41
- package/Runtime/Ad/AdModuleConfig.cs +3 -0
- package/Runtime/Ad/AmaGDK.Ads.cs +2 -1
- package/Runtime/AmaGDK.Analytics.cs +14 -7
- package/Runtime/AmaGDK.IAP.cs +35 -60
- package/Runtime/AmaGDK.RemoteConfig.cs +1 -1
- package/Runtime/AmaGDK.UserProfile.cs +2 -2
- package/Runtime/AmaGDK.cs +1 -1
- package/Runtime/Consent/AmaGDK.Consent.cs +35 -59
- package/Runtime/Core/GDKDebug.cs +43 -24
- package/Runtime/Internal/AmaGDK.Utils.cs +1 -1
- package/Runtime/Internal/ForceQuitMonitor.cs +1 -1
- package/Runtime/Utils/GDKFileUtils.cs +240 -104
- package/Runtime/Utils/GDKUtils.cs +33 -0
- package/package.json +1 -1
- package/Runtime/Consent/GDKPrivacyButton.cs +0 -25
- package/Runtime/Consent/GDKPrivacyButton.cs.meta +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -251,6 +251,11 @@ namespace Amanotes.Editor
|
|
|
251
251
|
|
|
252
252
|
public int callbackOrder { get; }
|
|
253
253
|
public void OnPreprocessBuild(BuildReport report)
|
|
254
|
+
{
|
|
255
|
+
OnPreprocessBuild();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public void OnPreprocessBuild()
|
|
254
259
|
{
|
|
255
260
|
_dicThirdPartyVersion = AmaGDKExtra.GetThirdPartyVersions();
|
|
256
261
|
_dicImportedGDKAdapter = GetImportedGDKAdapter();
|
|
@@ -269,10 +274,13 @@ namespace Amanotes.Editor
|
|
|
269
274
|
[PostProcessBuild(999)]
|
|
270
275
|
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
|
271
276
|
{
|
|
277
|
+
var maxAdapters = MaxEditorUtils.GetMaxAdapters().ToDictionary(kvp => $"{kvp.Key}-MaxAdapter", kvp => (object)kvp.Value);
|
|
278
|
+
var ironSourceAdapters = _dicIronSourceAdapterVersion.ToDictionary(kvp => $"{kvp.Key}-ISAdapter", kvp => kvp.Value);
|
|
272
279
|
var rawData = _dicThirdPartyVersion
|
|
273
280
|
.Concat(_dicExtraVersion)
|
|
274
|
-
.Concat(_dicIronSourceAdapterVersion.ToDictionary(kvp => kvp.Key, kvp => (object)("IS_" + kvp.Value)))
|
|
275
281
|
.ToDictionary(x => x.Key, x => x.Value);
|
|
282
|
+
rawData["MaxAdapters"] = maxAdapters;
|
|
283
|
+
rawData["IronSourceAdapters"] = ironSourceAdapters;
|
|
276
284
|
rawData["UnityVersion"] = Application.unityVersion;
|
|
277
285
|
string platform = "";
|
|
278
286
|
#if UNITY_ANDROID
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Xml.Linq;
|
|
5
|
+
|
|
6
|
+
namespace Amanotes.Editor
|
|
7
|
+
{
|
|
8
|
+
public class Versions
|
|
9
|
+
{
|
|
10
|
+
public string Unity;
|
|
11
|
+
public string Android;
|
|
12
|
+
public string Ios;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public class MaxEditorUtils
|
|
16
|
+
{
|
|
17
|
+
public static Dictionary<string, string> GetMaxAdapters()
|
|
18
|
+
{
|
|
19
|
+
var result = new Dictionary<string, string>();
|
|
20
|
+
string mediationPath = "Assets/MaxSdk/Mediation";
|
|
21
|
+
string[] adapterFolders = Directory.GetDirectories(mediationPath);
|
|
22
|
+
|
|
23
|
+
foreach (string adapterFolder in adapterFolders)
|
|
24
|
+
{
|
|
25
|
+
string adapterName = new DirectoryInfo(adapterFolder).Name;
|
|
26
|
+
string dependencyPath = Path.Combine(adapterFolder, "Editor/Dependencies.xml");
|
|
27
|
+
Versions version = GetCurrentVersions(dependencyPath);
|
|
28
|
+
result.Add(adapterName, $"android_{version.Android}_ios_{version.Ios}");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public static Versions GetCurrentVersions(string dependencyPath)
|
|
35
|
+
{
|
|
36
|
+
XDocument dependency;
|
|
37
|
+
try
|
|
38
|
+
{
|
|
39
|
+
dependency = XDocument.Load(dependencyPath);
|
|
40
|
+
}
|
|
41
|
+
#pragma warning disable 0168
|
|
42
|
+
catch (IOException exception)
|
|
43
|
+
#pragma warning restore 0168
|
|
44
|
+
{
|
|
45
|
+
// Couldn't find the dependencies file. The plugin is not installed.
|
|
46
|
+
return new Versions();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// <dependencies>
|
|
50
|
+
// <androidPackages>
|
|
51
|
+
// <androidPackage spec="com.applovin.mediation:network_name-adapter:1.2.3.4" />
|
|
52
|
+
// </androidPackages>
|
|
53
|
+
// <iosPods>
|
|
54
|
+
// <iosPod name="AppLovinMediationNetworkNameAdapter" version="2.3.4.5" />
|
|
55
|
+
// </iosPods>
|
|
56
|
+
// </dependencies>
|
|
57
|
+
string androidVersion = null;
|
|
58
|
+
string iosVersion = null;
|
|
59
|
+
var dependenciesElement = dependency.Element("dependencies");
|
|
60
|
+
if (dependenciesElement != null)
|
|
61
|
+
{
|
|
62
|
+
var androidPackages = dependenciesElement.Element("androidPackages");
|
|
63
|
+
if (androidPackages != null)
|
|
64
|
+
{
|
|
65
|
+
var adapterPackage = androidPackages.Descendants().FirstOrDefault(element => element.Name.LocalName.Equals("androidPackage")
|
|
66
|
+
&& element.FirstAttribute.Name.LocalName.Equals("spec")
|
|
67
|
+
&& element.FirstAttribute.Value.StartsWith("com.applovin"));
|
|
68
|
+
if (adapterPackage != null)
|
|
69
|
+
{
|
|
70
|
+
androidVersion = adapterPackage.FirstAttribute.Value.Split(':').Last();
|
|
71
|
+
// Hack alert: Some Android versions might have square brackets to force a specific version. Remove them if they are detected.
|
|
72
|
+
if (androidVersion.StartsWith("["))
|
|
73
|
+
{
|
|
74
|
+
androidVersion = androidVersion.Trim('[', ']');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var iosPods = dependenciesElement.Element("iosPods");
|
|
80
|
+
if (iosPods != null)
|
|
81
|
+
{
|
|
82
|
+
var adapterPod = iosPods.Descendants().FirstOrDefault(element => element.Name.LocalName.Equals("iosPod")
|
|
83
|
+
&& element.FirstAttribute.Name.LocalName.Equals("name")
|
|
84
|
+
&& element.FirstAttribute.Value.StartsWith("AppLovin"));
|
|
85
|
+
if (adapterPod != null)
|
|
86
|
+
{
|
|
87
|
+
iosVersion = adapterPod.Attributes().First(attribute => attribute.Name.LocalName.Equals("version")).Value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var currentVersions = new Versions();
|
|
93
|
+
if (androidVersion != null && iosVersion != null)
|
|
94
|
+
{
|
|
95
|
+
currentVersions.Unity = string.Format("android_{0}_ios_{1}", androidVersion, iosVersion);
|
|
96
|
+
currentVersions.Android = androidVersion;
|
|
97
|
+
currentVersions.Ios = iosVersion;
|
|
98
|
+
}
|
|
99
|
+
else if (androidVersion != null)
|
|
100
|
+
{
|
|
101
|
+
currentVersions.Unity = string.Format("android_{0}", androidVersion);
|
|
102
|
+
currentVersions.Android = androidVersion;
|
|
103
|
+
}
|
|
104
|
+
else if (iosVersion != null)
|
|
105
|
+
{
|
|
106
|
+
currentVersions.Unity = string.Format("ios_{0}", iosVersion);
|
|
107
|
+
currentVersions.Ios = iosVersion;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return currentVersions;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -361,20 +361,18 @@ namespace Amanotes.Editor
|
|
|
361
361
|
internal static List<IronSourceSDKAdapter> IronSourceAdapter()
|
|
362
362
|
{
|
|
363
363
|
var listAdapter = new List<IronSourceSDKAdapter>();
|
|
364
|
-
const string
|
|
364
|
+
const string IRON_SOURCE_PATH = "Assets/IronSource";
|
|
365
|
+
const string LEVEL_PLAY_PATH = "Assets/LevelPlay";
|
|
365
366
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
string[] filesIRadapter = Directory.GetFiles(IRONSOURCE_PATH, "IS*AdapterDependencies.xml", SearchOption.AllDirectories);
|
|
367
|
+
var irsFiles = Directory.Exists(IRON_SOURCE_PATH) ? Directory.GetFiles(IRON_SOURCE_PATH, "IS*AdapterDependencies.xml", SearchOption.AllDirectories).ToList() : new List<string>();
|
|
368
|
+
var levelPlayFiles = Directory.Exists(LEVEL_PLAY_PATH) ? Directory.GetFiles(LEVEL_PLAY_PATH, "IS*AdapterDependencies.xml", SearchOption.AllDirectories).ToList() : new List<string>();
|
|
369
|
+
|
|
370
|
+
var adapterFiles = irsFiles.Concat(levelPlayFiles).ToList();
|
|
372
371
|
|
|
373
|
-
if (
|
|
374
|
-
|
|
372
|
+
if (adapterFiles.Count <= 0) return listAdapter;
|
|
373
|
+
foreach (string filePath in adapterFiles)
|
|
375
374
|
{
|
|
376
375
|
var Xdoc = new XmlDocument();
|
|
377
|
-
string filePath = filesIRadapter[i];
|
|
378
376
|
|
|
379
377
|
Xdoc.Load(filePath);
|
|
380
378
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/Ad/AdLogic.cs
CHANGED
|
@@ -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
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
351
|
+
if (Application.platform == RuntimePlatform.IPhonePlayer)
|
|
352
|
+
{
|
|
353
|
+
bool willSaveVolume = Config.ad.autoMute
|
|
354
|
+
&& AudioListener.volume > 0
|
|
355
|
+
&& Ads._savedVolume < 0;
|
|
357
356
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
357
|
+
bool willSaveTimeScale = Config.ad.autoTimeScale
|
|
358
|
+
&& Time.timeScale > 0
|
|
359
|
+
&& Ads._savedTimeScale < 0;
|
|
361
360
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
361
|
+
if (willSaveVolume)
|
|
362
|
+
{
|
|
363
|
+
Ads._savedVolume = AudioListener.volume;
|
|
364
|
+
AudioListener.volume = 0;
|
|
365
|
+
}
|
|
367
366
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
|
|
386
|
+
bool willRestoreTimeScale = Config.ad.autoTimeScale
|
|
387
|
+
&& Mathf.Approximately(Time.timeScale, 0)
|
|
388
|
+
&& Ads._savedTimeScale > 0;
|
|
387
389
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
390
|
+
if (willRestoreVolume)
|
|
391
|
+
{
|
|
392
|
+
AudioListener.volume = Ads._savedVolume;
|
|
393
|
+
Ads._savedVolume = -1;
|
|
394
|
+
}
|
|
393
395
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
package/Runtime/Ad/AmaGDK.Ads.cs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
722
|
+
if (adapters != null && adapters.Count > 0)
|
|
719
723
|
{
|
|
720
|
-
|
|
721
|
-
|
|
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()
|
package/Runtime/AmaGDK.IAP.cs
CHANGED
|
@@ -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 (
|
|
45
|
+
if (Adapter == null)
|
|
71
46
|
{
|
|
72
47
|
onComplete?.Invoke(false);
|
|
73
48
|
return;
|
|
74
49
|
}
|
|
75
|
-
|
|
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
|
|
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
|
-
|
|
203
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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}");
|
|
@@ -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
|
|
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 = "
|
|
30
|
+
public const string VERSION = "0.2.82-alpha.1";
|
|
31
31
|
|
|
32
32
|
internal static Status _status = Status.None;
|
|
33
33
|
internal static ConfigAsset _config = null;
|