com.amanotes.gdk 0.2.81-alpha.8 → 0.2.81
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/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
|
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.81";
|
|
31
31
|
|
|
32
32
|
internal static Status _status = Status.None;
|
|
33
33
|
internal static ConfigAsset _config = null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using Amanotes.Core.Internal;
|
|
3
3
|
using UnityEngine;
|
|
4
|
+
using UnityEngine.Serialization;
|
|
4
5
|
using static Amanotes.Core.GDKDebug;
|
|
5
6
|
|
|
6
7
|
namespace Amanotes.Core
|
|
@@ -10,6 +11,8 @@ namespace Amanotes.Core
|
|
|
10
11
|
public static partial class Consent //Public
|
|
11
12
|
{
|
|
12
13
|
private static readonly GDKTaskTracker _allConsentTaskTracker = new GDKTaskTracker();
|
|
14
|
+
|
|
15
|
+
public static void OnAllConsentsCompleted(Action onComplete) => _allConsentTaskTracker.RegisterOnCompleteCallback(onComplete);
|
|
13
16
|
public static void RequestAllConsents(Action onComplete)
|
|
14
17
|
{
|
|
15
18
|
_allConsentTaskTracker.RegisterOnCompleteCallback(onComplete);
|
|
@@ -72,21 +75,37 @@ namespace Amanotes.Core
|
|
|
72
75
|
onComplete?.Invoke(false);
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
78
|
+
|
|
79
|
+
void RequestATT()
|
|
80
|
+
{
|
|
81
|
+
ConsentHook.ATTRequest(
|
|
82
|
+
isAllowed =>
|
|
83
|
+
{
|
|
84
|
+
data.att = isAllowed ? Status.Allowed : Status.NotAllowed;
|
|
85
|
+
data.SaveJsonToFile(false);
|
|
86
|
+
onComplete?.Invoke(allowedATT);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
|
|
91
|
+
if (_config.autoGetConsent)
|
|
77
92
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
// Delay 1s due to iOS issue, ATT popup will not show if we request soon at app launch
|
|
94
|
+
GDKUtils.DelayCall(1f, RequestATT);
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
{
|
|
98
|
+
RequestATT();
|
|
99
|
+
}
|
|
82
100
|
}
|
|
83
101
|
}
|
|
84
|
-
|
|
85
102
|
}
|
|
86
103
|
|
|
87
104
|
public static partial class Consent //CMP
|
|
88
105
|
{
|
|
89
|
-
public static
|
|
106
|
+
public static readonly CMPConsent CMP = new CMPConsent();
|
|
107
|
+
|
|
108
|
+
public class CMPConsent
|
|
90
109
|
{
|
|
91
110
|
/// <summary>
|
|
92
111
|
/// Determines if a consent popup should be shown to the user and displays it if required.
|
|
@@ -101,7 +120,7 @@ namespace Amanotes.Core
|
|
|
101
120
|
/// </param>
|
|
102
121
|
/// <param name="onError">Callback invoked with an error message if the consent
|
|
103
122
|
/// form could not be loaded or shown.</param>
|
|
104
|
-
public
|
|
123
|
+
public void ShowConsentFormIfRequired(Action<bool> onComplete, Action<string> onError)
|
|
105
124
|
{
|
|
106
125
|
if (ConsentHook.ShowConsentFormIfRequired == null)
|
|
107
126
|
{
|
|
@@ -112,59 +131,17 @@ namespace Amanotes.Core
|
|
|
112
131
|
if (data.consentAlreadyShown)
|
|
113
132
|
{
|
|
114
133
|
Log("[Consent] Consent form has already been shown");
|
|
115
|
-
onComplete?.Invoke(data.
|
|
134
|
+
onComplete?.Invoke(data.canRequestAds);
|
|
116
135
|
return;
|
|
117
136
|
}
|
|
118
|
-
ConsentHook.ShowConsentFormIfRequired(
|
|
137
|
+
ConsentHook.ShowConsentFormIfRequired(canRequestAds =>
|
|
119
138
|
{
|
|
120
|
-
data.
|
|
139
|
+
data.canRequestAds = canRequestAds;
|
|
121
140
|
data.consentAlreadyShown = true;
|
|
122
|
-
data.SaveJsonToFile();
|
|
123
|
-
onComplete?.Invoke(
|
|
141
|
+
data.SaveJsonToFile(false);
|
|
142
|
+
onComplete?.Invoke(canRequestAds);
|
|
124
143
|
}, onError);
|
|
125
144
|
}
|
|
126
|
-
|
|
127
|
-
/// <summary>
|
|
128
|
-
/// Forces the consent popup to be shown to the user, regardless of previous
|
|
129
|
-
/// consent status.
|
|
130
|
-
/// </summary>
|
|
131
|
-
/// <param name="onComplete">Callback invoked with a boolean indicating the
|
|
132
|
-
/// ConsentInformation.CanRequestAds() result
|
|
133
|
-
/// </param>
|
|
134
|
-
/// <param name="onError">Callback invoked with an error message if the consent
|
|
135
|
-
/// form could not be loaded or shown.</param>
|
|
136
|
-
public static void ShowPrivacyForm(Action<bool> onComplete, Action<string> onError)
|
|
137
|
-
{
|
|
138
|
-
if (ConsentHook.CheckPrivacyOptionsRequired == null)
|
|
139
|
-
{
|
|
140
|
-
LogWarning("[Consent] ConsentHook.ShowPrivacyForm is not implemented");
|
|
141
|
-
onError?.Invoke("ShowPrivacyForm is not implemented");
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
ConsentHook.ShowPrivacyForm(onComplete, onError);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/// <summary>
|
|
148
|
-
/// Determines whether privacy options are required for the current user.
|
|
149
|
-
/// Updates the consent information before returning the result.
|
|
150
|
-
/// </summary>
|
|
151
|
-
/// <param name="onComplete">Callback invoked with `true` if privacy options are required, otherwise `false`.</param>
|
|
152
|
-
public static void CheckPrivacyOptionsRequired(Action<bool> onComplete)
|
|
153
|
-
{
|
|
154
|
-
if (ConsentHook.CheckPrivacyOptionsRequired == null)
|
|
155
|
-
{
|
|
156
|
-
LogWarning("[Consent] ConsentHook.CheckPrivacyOptionsRequired is not implemented");
|
|
157
|
-
onComplete?.Invoke(false);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
ConsentHook.CheckPrivacyOptionsRequired(onComplete);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
[Obsolete("Use ShowPrivacyForm instead")]
|
|
164
|
-
public static void ForceShowPopup(Action<bool> onComplete)
|
|
165
|
-
{
|
|
166
|
-
ShowPrivacyForm(onComplete, s => onComplete?.Invoke(false));
|
|
167
|
-
}
|
|
168
145
|
}
|
|
169
146
|
}
|
|
170
147
|
|
|
@@ -177,7 +154,7 @@ namespace Amanotes.Core
|
|
|
177
154
|
internal static bool checkedATT => data.att >= Status.Allowed;
|
|
178
155
|
internal static bool allowedATT => data.att == Status.Allowed;
|
|
179
156
|
|
|
180
|
-
|
|
157
|
+
public enum Status
|
|
181
158
|
{
|
|
182
159
|
None,
|
|
183
160
|
NotRequired,
|
|
@@ -201,14 +178,13 @@ namespace Amanotes.Core
|
|
|
201
178
|
{
|
|
202
179
|
[SerializeField] internal AmaGDK.Consent.Status att;
|
|
203
180
|
[SerializeField] internal bool consentAlreadyShown;
|
|
204
|
-
[
|
|
181
|
+
[FormerlySerializedAs("canShowAds")]
|
|
182
|
+
[SerializeField] internal bool canRequestAds;
|
|
205
183
|
}
|
|
206
184
|
|
|
207
185
|
public static class ConsentHook
|
|
208
186
|
{
|
|
209
187
|
public static Action<Action<bool>, Action<string>> ShowConsentFormIfRequired;
|
|
210
|
-
public static Action<Action<bool>, Action<string>> ShowPrivacyForm;
|
|
211
|
-
public static Action<Action<bool>> CheckPrivacyOptionsRequired;
|
|
212
188
|
public static Action<Action<bool>> ATTRequest;
|
|
213
189
|
}
|
|
214
190
|
}
|