com.amanotes.gdk 0.2.81-alpha.11 → 0.2.81-alpha.13
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/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/AmaGDK.IAP.cs +34 -59
- package/Runtime/AmaGDK.cs +1 -1
- package/Runtime/Core/GDKDebug.cs +2 -2
- package/Runtime/Utils/GDKUtils.cs +33 -0
- package/package.json +1 -1
|
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/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();
|
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.
|
|
30
|
+
public const string VERSION = "v0.2.81-alpha.13";
|
|
31
31
|
|
|
32
32
|
internal static Status _status = Status.None;
|
|
33
33
|
internal static ConfigAsset _config = null;
|
package/Runtime/Core/GDKDebug.cs
CHANGED
|
@@ -100,7 +100,7 @@ namespace Amanotes.Core
|
|
|
100
100
|
public static void Log(string message)
|
|
101
101
|
{
|
|
102
102
|
if (AmaGDK.logLevel < LogLevel.Verbose) return;
|
|
103
|
-
using (NoStackTrace.Log)
|
|
103
|
+
using (GDKUtils.isOnMainThread ? NoStackTrace.Log: NoStackTraceNull)
|
|
104
104
|
{
|
|
105
105
|
Debug.Log($"AmaGDK {message}");
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ namespace Amanotes.Core
|
|
|
108
108
|
|
|
109
109
|
public static void ForceLog(string message)
|
|
110
110
|
{
|
|
111
|
-
using (NoStackTrace.Log)
|
|
111
|
+
using (GDKUtils.isOnMainThread ? NoStackTrace.Log: NoStackTraceNull)
|
|
112
112
|
{
|
|
113
113
|
Debug.Log($"AmaGDK {message}");
|
|
114
114
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using System.Collections;
|
|
2
3
|
using UnityEngine;
|
|
3
4
|
using static Amanotes.Core.GDKDebug;
|
|
4
5
|
|
|
@@ -96,5 +97,37 @@ namespace Amanotes.Core.Internal
|
|
|
96
97
|
|
|
97
98
|
LogWarning(message);
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
public static IEnumerator WaitForSecondsRealtime(float duration, bool focusOnly = true)
|
|
102
|
+
{
|
|
103
|
+
if (!focusOnly)
|
|
104
|
+
{
|
|
105
|
+
yield return new WaitForSecondsRealtime(duration);
|
|
106
|
+
yield break;
|
|
107
|
+
}
|
|
108
|
+
float elapsedTime = 0f;
|
|
109
|
+
float lastTimeStamp = Time.realtimeSinceStartup;
|
|
110
|
+
bool focusChangedSinceLastFrame = false;
|
|
111
|
+
Action<bool> onApplicationFocusCallback = _ => focusChangedSinceLastFrame = true;
|
|
112
|
+
Application.focusChanged += onApplicationFocusCallback;
|
|
113
|
+
|
|
114
|
+
while (elapsedTime < duration)
|
|
115
|
+
{
|
|
116
|
+
if (Application.isFocused)
|
|
117
|
+
{
|
|
118
|
+
if (focusChangedSinceLastFrame)
|
|
119
|
+
{
|
|
120
|
+
lastTimeStamp = Time.realtimeSinceStartup;
|
|
121
|
+
focusChangedSinceLastFrame = false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
elapsedTime += Time.realtimeSinceStartup - lastTimeStamp;
|
|
125
|
+
lastTimeStamp = Time.realtimeSinceStartup;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
yield return null;
|
|
129
|
+
}
|
|
130
|
+
Application.focusChanged -= onApplicationFocusCallback;
|
|
131
|
+
}
|
|
99
132
|
}
|
|
100
133
|
}
|