com.amanotes.gdk 0.2.21 → 0.2.23

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.23 - 2023-10-18]
4
+ - Fix UserProfile out of main thread
5
+ - Handle multiple Firebase's dependency check
6
+
7
+ ## [0.2.22 - 2023-10-11]
8
+ - Get adapter info
9
+
3
10
  ## [0.2.21 - 2023-10-11]
4
11
  - RevenueCat adapter v6.0.0
5
12
  - Handle early Firebase call
Binary file
Binary file
Binary file
Binary file
Binary file
package/Runtime/AmaGDK.cs CHANGED
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Collections.Generic;
3
4
  using System.Diagnostics;
4
5
  using System.IO;
5
6
  using System.Text;
@@ -8,21 +9,24 @@ using Amanotes.Core.Internal;
8
9
  using UnityEngine;
9
10
  using static Amanotes.Core.Internal.Logging;
10
11
  using static Amanotes.Core.Internal.Messsage;
11
- using Debug = System.Diagnostics.Debug;
12
12
 
13
13
  namespace Amanotes.Core
14
14
  {
15
15
  public partial class AmaGDK : MonoBehaviour
16
16
  {
17
- public const string VERSION = "0.2.21";
17
+ public const string VERSION = "0.2.23";
18
18
 
19
19
  internal static AmaGDK _instance;
20
20
  internal static Status _status = Status.None;
21
21
  internal static Action _onReadyCallback;
22
+ internal static Action<AdapterInfo> _onAdapterReadyCallback;
22
23
  internal static bool _allowInit = false;
23
24
  public bool autoInit = true;
24
25
 
25
26
  private static ConfigAsset _config = null;
27
+ private static readonly Dictionary<string, AdapterInfo> _adapters = new Dictionary<string, AdapterInfo>();
28
+ private static readonly List<string> _firebaseServices = new List<string>() { AdapterID.FIREBASE_REMOTE_CONFIG, AdapterID.FIREBASE_ANALYTICS };
29
+
26
30
  internal static ConfigAsset Config
27
31
  {
28
32
  get
@@ -61,7 +65,7 @@ namespace Amanotes.Core
61
65
  throw new Exception("[AmaGDK] " + CONFIG_NOT_FOUND);
62
66
  }
63
67
 
64
- yield return User.Init();
68
+ yield return StartCoroutine(User.Init());
65
69
 
66
70
  float time = 0;
67
71
  float timeout = 10;
@@ -83,7 +87,7 @@ namespace Amanotes.Core
83
87
 
84
88
  _status = Status.Initialize;
85
89
  float startTime = Time.realtimeSinceStartup;
86
- StringBuilder adapterInfo = new StringBuilder();
90
+ StringBuilder adapterAnnounce = new StringBuilder();
87
91
 
88
92
  // sort on priority
89
93
  Adapter.listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
@@ -104,8 +108,18 @@ namespace Amanotes.Core
104
108
  break;
105
109
  }
106
110
 
107
- adapterInfo.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL", adapter.adapterId, adapter.adapterVersion));
111
+ if (adapter.IsReady && _firebaseServices.Contains(adapter.adapterId))
112
+ {
113
+ firebaseResolved = true;
114
+ }
115
+
116
+ var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady);
117
+ _adapters.Add(adapter.adapterId, adapterInfo);
118
+ _onAdapterReadyCallback?.Invoke(adapterInfo);
119
+ adapterAnnounce.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL",
120
+ adapter.adapterId, adapter.adapterVersion));
108
121
  }
122
+ _onAdapterReadyCallback = null;
109
123
 
110
124
  // Init modules (Adapter managers)
111
125
  Analytics.Init();
@@ -115,7 +129,7 @@ namespace Amanotes.Core
115
129
  _status = Status.Ready;
116
130
  _onReadyCallback?.Invoke();
117
131
  _onReadyCallback = null;
118
- Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterInfo.ToString()}");
132
+ Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterAnnounce.ToString()}");
119
133
  }
120
134
 
121
135
  void RegisterUnityCallback(AdapterContext adapter)
@@ -155,6 +169,7 @@ namespace Amanotes.Core
155
169
  public partial class AmaGDK // PUBLIC APIS
156
170
  {
157
171
  public static bool isReady => _status == Status.Ready;
172
+ public static bool firebaseResolved { get; private set; }
158
173
 
159
174
  public static void Init(Action onReady = null)
160
175
  {
@@ -188,12 +203,40 @@ namespace Amanotes.Core
188
203
  {
189
204
  if (onReady == null)
190
205
  {
191
- LogWarning("Can not add a null callback!");
206
+ LogWarning("Cannot add a null callback!");
192
207
  return;
193
208
  }
194
209
  _onReadyCallback -= onReady;
195
210
  _onReadyCallback += onReady;
196
211
  }
212
+
213
+ public static void SetAdapterReadyCallback(Action<AdapterInfo> onAdapterReady)
214
+ {
215
+ if (onAdapterReady == null)
216
+ {
217
+ LogWarning("Cannot add a null callback!");
218
+ return;
219
+ }
220
+ _onAdapterReadyCallback -= onAdapterReady;
221
+ _onAdapterReadyCallback += onAdapterReady;
222
+ }
223
+
224
+ public static AdapterInfo GetAdapterInfo(string id)
225
+ {
226
+ if (string.IsNullOrWhiteSpace(id))
227
+ {
228
+ LogWarning("Please provide Adapter ID to get the info.");
229
+ return default;
230
+ }
231
+
232
+ if (!_adapters.ContainsKey(id))
233
+ {
234
+ LogWarning($"Adapter {id} is not found.");
235
+ return default;
236
+ }
237
+
238
+ return _adapters[id];
239
+ }
197
240
  }
198
241
 
199
242
  public partial class AmaGDK
@@ -238,7 +281,7 @@ namespace Amanotes.Core
238
281
  }
239
282
  }
240
283
 
241
- public partial class AmaGDK // Switch dev mode
284
+ public partial class AmaGDK // Switch dev mode
242
285
  {
243
286
  [ContextMenu("Change Dev Mode")]
244
287
  public void ChangeDevMode()
@@ -281,4 +324,18 @@ namespace Amanotes.Core
281
324
  File.WriteAllText(manifestPath, manifestJson);
282
325
  }
283
326
  }
327
+
328
+ public struct AdapterInfo
329
+ {
330
+ public string id;
331
+ public string version;
332
+ public bool isReady;
333
+
334
+ public AdapterInfo(string id, string version, bool isReady)
335
+ {
336
+ this.id = id;
337
+ this.version = version;
338
+ this.isReady = isReady;
339
+ }
340
+ }
284
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",