com.amanotes.gdk 0.2.81-alpha.8 → 0.2.84

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/Editor/Extra/SDKVersionTracking.cs +20 -1
  3. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  4. package/Extra/AutoEventQC.unitypackage +0 -0
  5. package/Extra/CheckDiskSpace.unitypackage +0 -0
  6. package/Extra/Consent.unitypackage +0 -0
  7. package/Extra/CrashlyticHook.unitypackage +0 -0
  8. package/Extra/ForceUpdate.unitypackage +0 -0
  9. package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
  10. package/Extra/PostProcessor.unitypackage +0 -0
  11. package/Packages/AmaGDKConfig.unitypackage +0 -0
  12. package/Packages/AmaGDKExample.unitypackage +0 -0
  13. package/Packages/AmaGDKTest.unitypackage +0 -0
  14. package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
  15. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  16. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  17. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  18. package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
  19. package/Packages/IronSourceAdapter.unitypackage +0 -0
  20. package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
  21. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  22. package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
  23. package/Runtime/Ad/AdLogic.cs +44 -41
  24. package/Runtime/Ad/AdModuleConfig.cs +3 -0
  25. package/Runtime/Ad/AmaGDK.Ads.cs +2 -1
  26. package/Runtime/AmaGDK.Analytics.cs +14 -7
  27. package/Runtime/AmaGDK.IAP.cs +35 -60
  28. package/Runtime/AmaGDK.RemoteConfig.cs +5 -5
  29. package/Runtime/AmaGDK.UserProfile.cs +2 -2
  30. package/Runtime/AmaGDK.asmdef +3 -1
  31. package/Runtime/AmaGDK.cs +1 -1
  32. package/Runtime/Consent/AmaGDK.Consent.cs +35 -59
  33. package/Runtime/Core/GDKDebug.cs +43 -24
  34. package/Runtime/Internal/AmaGDK.Utils.cs +1 -1
  35. package/Runtime/Internal/ForceQuitMonitor.cs +1 -1
  36. package/Runtime/Utils/GDKFileUtils.cs +240 -104
  37. package/Runtime/Utils/GDKUtils.cs +33 -0
  38. package/package.json +30 -18
  39. package/Runtime/Consent/GDKPrivacyButton.cs +0 -25
  40. package/Runtime/Consent/GDKPrivacyButton.cs.meta +0 -3
@@ -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
- ConsentHook.ATTRequest(isAllowed =>
91
+ if (_config.autoGetConsent)
77
92
  {
78
- data.att = isAllowed ? Status.Allowed : Status.NotAllowed;
79
- data.SaveJsonToFile();
80
- onComplete?.Invoke(allowedATT);
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 class CMP
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 static void ShowConsentFormIfRequired(Action<bool> onComplete, Action<string> onError)
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.canShowAds);
134
+ onComplete?.Invoke(data.canRequestAds);
116
135
  return;
117
136
  }
118
- ConsentHook.ShowConsentFormIfRequired(canShowAd =>
137
+ ConsentHook.ShowConsentFormIfRequired(canRequestAds =>
119
138
  {
120
- data.canShowAds = canShowAd;
139
+ data.canRequestAds = canRequestAds;
121
140
  data.consentAlreadyShown = true;
122
- data.SaveJsonToFile();
123
- onComplete?.Invoke(canShowAd);
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
- internal enum Status
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
- [SerializeField] internal bool canShowAds;
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
  }
@@ -11,11 +11,12 @@ namespace Amanotes.Core
11
11
  Warning,
12
12
  Verbose
13
13
  }
14
-
15
- internal struct NoStackTrace : IDisposable
14
+
15
+ #if GDK_REMOVE_STACKTRACE
16
+ internal readonly struct NoStackTrace : IDisposable
16
17
  {
17
- internal LogType logType;
18
- internal StackTraceLogType stackTraceType;
18
+ internal readonly LogType logType;
19
+ internal readonly StackTraceLogType stackTraceType;
19
20
 
20
21
  internal NoStackTrace(LogType logType)
21
22
  {
@@ -34,8 +35,21 @@ namespace Amanotes.Core
34
35
  public static NoStackTrace Log => new NoStackTrace(LogType.Log);
35
36
  }
36
37
 
38
+ internal readonly struct NoStackTraceNull: IDisposable
39
+ {
40
+ public void Dispose()
41
+ {
42
+
43
+ }
44
+ }
45
+ #endif
46
+
37
47
  public class GDKDebug
38
48
  {
49
+ #if GDK_REMOVE_STACKTRACE
50
+ internal static readonly IDisposable NoStackTraceNull = new NoStackTraceNull();
51
+ #endif
52
+
39
53
  public static Action<string> logNonfatalErrorHook = null;
40
54
  private static readonly HashSet<string> nonFatalDict = new HashSet<string>();
41
55
  private static readonly HashSet<string> logWarningDict = new HashSet<string>();
@@ -49,7 +63,9 @@ namespace Amanotes.Core
49
63
  if (!logWarningDict.Add(key)) return;
50
64
  }
51
65
 
52
- using (NoStackTrace.Warning)
66
+ #if GDK_REMOVE_STACKTRACE
67
+ using (GDKUtils.isOnMainThread ? NoStackTrace.Warning: NoStackTraceNull)
68
+ #endif
53
69
  {
54
70
  Debug.LogWarning($"AmaGDK {message}");
55
71
  }
@@ -57,45 +73,46 @@ namespace Amanotes.Core
57
73
  public static void LogWarning(string message)
58
74
  {
59
75
  if (AmaGDK.logLevel < LogLevel.Warning) return;
60
- using (NoStackTrace.Warning)
76
+ #if GDK_REMOVE_STACKTRACE
77
+ using (GDKUtils.isOnMainThread ? NoStackTrace.Warning: NoStackTraceNull)
78
+ #endif
61
79
  {
62
- Debug.LogWarning($"AmaGDK {message}");
80
+ Debug.LogWarning($"AmaGDK {message}");
63
81
  }
64
82
  }
65
83
  public static void LogError(string message)
66
84
  {
67
85
  if (AmaGDK.logLevel < LogLevel.Error) return;
68
- using (NoStackTrace.Error)
86
+ #if GDK_REMOVE_STACKTRACE
87
+ using (GDKUtils.isOnMainThread ? NoStackTrace.Error: NoStackTraceNull)
88
+ #endif
69
89
  {
70
- Debug.LogError($"AmaGDK {message}");
90
+ Debug.LogError($"AmaGDK {message}");
71
91
  }
72
92
 
73
93
  if (logNonfatalErrorHook == null) return;
74
94
 
75
95
  if (GDKUtils.isOnMainThread) // Most of the time
76
96
  {
77
- lock (nonFatalDict)
78
- {
79
- if (!nonFatalDict.Add(message)) return;
80
- }
81
- logNonfatalErrorHook(message);
97
+ LogNonFatalOnMainThread(message);
82
98
  return;
83
99
  }
84
100
 
85
- GDKUtils.DoOnMainThread(() =>
86
- {
87
- lock (nonFatalDict)
88
- {
89
- if (!nonFatalDict.Add(message)) return; // LogOnce
90
- }
91
- logNonfatalErrorHook(message);
92
- });
101
+ GDKUtils.DoOnMainThread(() => { LogNonFatalOnMainThread(message); });
102
+ }
103
+
104
+ private static void LogNonFatalOnMainThread(string message)
105
+ {
106
+ if (!nonFatalDict.Add(message)) return;
107
+ logNonfatalErrorHook(message);
93
108
  }
94
109
 
95
110
  public static void Log(string message)
96
111
  {
97
112
  if (AmaGDK.logLevel < LogLevel.Verbose) return;
98
- using (NoStackTrace.Log)
113
+ #if GDK_REMOVE_STACKTRACE
114
+ using (GDKUtils.isOnMainThread ? NoStackTrace.Log: NoStackTraceNull)
115
+ #endif
99
116
  {
100
117
  Debug.Log($"AmaGDK {message}");
101
118
  }
@@ -103,7 +120,9 @@ namespace Amanotes.Core
103
120
 
104
121
  public static void ForceLog(string message)
105
122
  {
106
- using (NoStackTrace.Log)
123
+ #if GDK_REMOVE_STACKTRACE
124
+ using (GDKUtils.isOnMainThread ? NoStackTrace.Log: NoStackTraceNull)
125
+ #endif
107
126
  {
108
127
  Debug.Log($"AmaGDK {message}");
109
128
  }
@@ -200,7 +200,7 @@ namespace Amanotes.Core.Internal
200
200
  return GDKFileUtils.LoadJsonFromFile(instance);
201
201
  }
202
202
 
203
- internal static void SaveJsonToFile<T>(this T instance, bool immediately = true) where T: IJsonFile
203
+ internal static void SaveJsonToFile<T>(this T instance, bool immediately) where T: IJsonFile
204
204
  {
205
205
  GDKFileUtils.SaveJsonToFile(instance, immediately);
206
206
  }
@@ -34,7 +34,7 @@ namespace Amanotes.Core.Internal
34
34
  internal void SaveIfDirty(bool forceSave = false)
35
35
  {
36
36
  if (!isDirty && !forceSave) return;
37
- this.SaveJsonToFile();
37
+ this.SaveJsonToFile(false);
38
38
  isDirty = false;
39
39
  }
40
40
  }