com.amanotes.gdk 0.1.19 → 0.1.21

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 (44) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/Packages/AmaGDKConfig.unitypackage +0 -0
  3. package/Packages/AmaGDKExample.unitypackage +0 -0
  4. package/Packages/AmaGDKTest.unitypackage +0 -0
  5. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  6. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  7. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  8. package/{Samples~/Example/AmaGDKExample.unity.meta → Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta} +1 -1
  9. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  10. package/Runtime/AmaGDK.Adapters.cs +19 -0
  11. package/Runtime/AmaGDK.Ads.cs +2 -16
  12. package/Runtime/AmaGDK.RemoteConfig.cs +282 -55
  13. package/Runtime/AmaGDK.Utils.cs +42 -13
  14. package/Runtime/AmaGDK.WebUtils.cs +6 -9
  15. package/Runtime/AmaGDK.cs +5 -4
  16. package/package.json +1 -1
  17. package/Packages/AppsflyerAdapter_v6.5.4.unitypackage +0 -0
  18. package/Runtime/AmaPassport/AmaGDK.AmaPassport.cs +0 -444
  19. package/Runtime/AmaPassport/AmaGDK.AmaPassport.cs.meta +0 -11
  20. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java +0 -7
  21. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java.meta +0 -32
  22. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs +0 -96
  23. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs.meta +0 -11
  24. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java +0 -79
  25. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java.meta +0 -32
  26. package/Runtime/AmaPassport/Plugins/Android.meta +0 -8
  27. package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs +0 -59
  28. package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs.meta +0 -11
  29. package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm +0 -52
  30. package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm.meta +0 -33
  31. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h +0 -281
  32. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h.meta +0 -33
  33. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m +0 -1393
  34. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m.meta +0 -33
  35. package/Runtime/AmaPassport/Plugins/iOS.meta +0 -8
  36. package/Runtime/AmaPassport/Plugins.meta +0 -8
  37. package/Runtime/AmaPassport.meta +0 -8
  38. package/Samples~/Example/AmaGDKExample.cs +0 -87
  39. package/Samples~/Example/AmaGDKExample.cs.meta +0 -11
  40. package/Samples~/Example/AmaGDKExample.unity +0 -3114
  41. package/Sample~/Example/AmaGDKExample.cs +0 -87
  42. package/Sample~/Example/AmaGDKExample.cs.meta +0 -11
  43. package/Sample~/Example/AmaGDKExample.unity +0 -3114
  44. package/Sample~/Example/AmaGDKExample.unity.meta +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.21 - 2023-05-22]
4
+ ### Add Remote Config module + Firebase Remote Config adapter
5
+ ### Rearrange adapters
6
+ ### Add "enableAnalyticsCollection" to Firebase Analytics config
7
+ ### Fix AmaGDK to compatible with Unity 2019
8
+
9
+ ## [0.1.20 - 2023-04-20]
10
+ ### Refactor Adapter architure to support reading adapter config from Core
11
+ ### Add session stat for Analytics module
12
+ ### Unit test for Json parser and Analytics module
13
+
3
14
  ## [0.1.19 - 2023-04-11]
4
15
  ### Move AmaGDKTest out of AmaGDKCore
5
16
 
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 10026e46727964068991024d2146c0c7
2
+ guid: c4acdfbf7c40646b6b8d379d00b3df5d
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -86,6 +86,25 @@ namespace Amanotes.Core.Internal
86
86
  return result;
87
87
  }
88
88
 
89
+ public static T GetSingleAdapter<T>() where T: class
90
+ {
91
+ var adapters = Adapter.FindAll<T>();
92
+
93
+ if (adapters == null || adapters.Count < 1)
94
+ {
95
+ LogError($"Not found adapter for <{nameof(T)}>!");
96
+ return null;
97
+ }
98
+
99
+ if (adapters.Count > 1)
100
+ {
101
+ LogError($"Multiple adapters detected. <{nameof(T)}> supports only one adapter!");
102
+ return null;
103
+ }
104
+
105
+ return adapters[0].GetAdapterApi<T>();
106
+ }
107
+
89
108
  public static T GetConfig<T>() where T : ConfigAsset
90
109
  {
91
110
  return (T)AmaGDK.Config;
@@ -63,22 +63,8 @@ namespace Amanotes.Core
63
63
  public static Action<string> OnRewardedVideoFailCallback;
64
64
 
65
65
  public static void Init()
66
- {
67
- var adsModules = Adapter.FindAll<IAds>();
68
-
69
- if (adsModules == null || adsModules.Count < 1)
70
- {
71
- LogError("Ads module not found!");
72
- return;
73
- }
74
-
75
- if (adsModules.Count > 1)
76
- {
77
- LogError("Multiple Ads modules is not supported!");
78
- return;
79
- }
80
-
81
- adsModule = adsModules[0].GetAdapterApi<IAds>();
66
+ {
67
+ adsModule =Adapter.GetSingleAdapter<IAds>();
82
68
  }
83
69
 
84
70
  public static void RequestBanner(BannerPosition position)
@@ -1,116 +1,343 @@
1
1
  using System;
2
- using System.Collections;
3
2
  using System.Collections.Generic;
4
- using System.Threading.Tasks;
3
+ using System.IO;
4
+ using System.Text;
5
5
  using UnityEngine;
6
6
 
7
7
  using Amanotes.Core.Internal;
8
8
  using static Amanotes.Core.Internal.Logging;
9
- using Firebase.RemoteConfig;
10
9
 
11
10
  namespace Amanotes.Core
12
11
  {
13
12
  public partial class AmaGDK //Remote Config
14
13
  {
14
+ public enum RemoteConfigSource
15
+ {
16
+ DefaultAsset,
17
+ DefaultFile,
18
+ Cache,
19
+ Internet
20
+ }
21
+
15
22
  [Serializable]
16
23
  public partial class RemoteConfig //Public
17
24
  {
18
- internal static IRemoteConfig remoteConfigAdapter;
25
+ public static Dictionary<string, string> DictConfig { get { return dictConfig; } }
26
+ public static RemoteConfigSource Source { private set; get; }
27
+ static bool? _cacheExisted = null;
28
+ public static bool HasCache {
29
+ get
30
+ {
31
+ if (_cacheExisted == null)
32
+ _cacheExisted = FileUtils.Exist(fileName);
33
+ return _cacheExisted.GetValueOrDefault();
34
+ }
35
+ }
19
36
 
20
- public static void Init()
37
+ public static T ParseConfig<T>(T config = null) where T : class, new()
21
38
  {
22
- var remoteConfigAdapters = Adapter.FindAll<IRemoteConfig>();
39
+ if (config == null)
40
+ config = new T();
23
41
 
24
- if (remoteConfigAdapters == null || remoteConfigAdapters.Count < 1)
42
+ var configInJson = GetConfigAsJson();
43
+ if (string.IsNullOrEmpty(configInJson))
25
44
  {
26
- LogError("Not found remote config module!");
27
- return;
45
+ LogWarning("[RemoteConfig] The config is empty");
46
+ return config;
28
47
  }
29
48
 
30
- if (remoteConfigAdapters.Count > 1)
49
+ try
50
+ {
51
+ return config = JsonUtility.FromJson<T>(configInJson);
52
+ }
53
+ catch (Exception e)
31
54
  {
32
- LogError("Multiple remote config adapters is not supported!");
33
- return;
55
+ LogError("[RemoteConfig] Cannot parse remote config file. Error: " + e.Message);
56
+ return config;
34
57
  }
35
-
36
- remoteConfigAdapter = remoteConfigAdapters[0].GetAdapterApi<IRemoteConfig>();
37
58
  }
38
59
 
39
- public static Task SetDefault(IDictionary<string, object> config)
60
+ public static T Get<T>(string key, T defaultValue = default(T))
40
61
  {
41
- if (AdapterNotReady()) return Task.FromException(new Exception("Unable to set default value for remote config"));
42
- return remoteConfigAdapter.SetDefault(config);
62
+ if (dictConfig.ContainsKey(key))
63
+ return (T)Convert.ChangeType(dictConfig[key], typeof(T));
64
+ return defaultValue;
43
65
  }
44
66
 
45
- public static Task Fetch()
67
+ public static string GetConfigAsJson()
46
68
  {
47
- if (AdapterNotReady()) return Task.FromException(new Exception("Unable to fetch remote config"));
48
- return remoteConfigAdapter.Fetch();
69
+ return JsonUtils.DictionaryToJson(dictConfig);
70
+ }
71
+ }
72
+
73
+ public partial class RemoteConfig //Internal
74
+ {
75
+ internal enum FetchState
76
+ {
77
+ None,
78
+ ResolveDependencies,
79
+ CheckInternet,
80
+ Fetch,
81
+ SaveCache,
82
+
83
+ LoadCache,
84
+ LoadDefaultFile,
85
+ LoadDefaultAsset,
86
+
87
+ Success,
88
+ Fail
49
89
  }
50
90
 
51
- public static Task Activate()
91
+ static Dictionary<string, string> dictConfig = new Dictionary<string, string>();
92
+ static string fileName = $"{nameof(RemoteConfig)}.kv";
93
+ static string defaultConfigFileName = "remote_config_defaults";
94
+
95
+ static FetchState _state = FetchState.None;
96
+ internal static FetchState State { get { return _state; } }
97
+ static readonly Dictionary<FetchState, Action[]> fetchSM = new Dictionary<FetchState, Action[]>
98
+ {
99
+ { FetchState.None, new Action[]{ ResolveDependency }},
100
+ { FetchState.ResolveDependencies, new Action[]{ LoadCache, CheckInternet}},
101
+ { FetchState.CheckInternet, new Action[]{ LoadCache, Fetch}},
102
+ { FetchState.Fetch, new Action[]{ LoadCache, SaveCache}},
103
+ { FetchState.SaveCache, new Action[]{ SetDone }},
104
+ { FetchState.LoadCache, new Action[]{ LoadDefaultFile, SetDone}},
105
+ { FetchState.LoadDefaultFile, new Action[]{ LoadDefaultAsset, SetDone}},
106
+ { FetchState.LoadDefaultAsset, new Action[]{ SetFail, SetDone}}
107
+ };
108
+
109
+ internal static IRemoteConfig adapter;
110
+ internal static Action<bool> onAdapterInitCompleteCallback;
111
+
112
+ internal static void NextState(bool result = true)
113
+ {
114
+ if (!fetchSM.TryGetValue(_state, out var actions))
115
+ {
116
+ LogWarning("[RemoteConfig] Invalid / Unsupported state: " + _state);
117
+ return;
118
+ }
119
+
120
+ if (actions.Length == 1)
121
+ {
122
+ actions[0]();
123
+ return;
124
+ }
125
+
126
+ actions[result ? 1 : 0]();
127
+ }
128
+
129
+ static void ResolveDependency()
52
130
  {
53
- if (AdapterNotReady()) return Task.FromException(new Exception("Unable to activate remote config"));
54
- return remoteConfigAdapter.Activate();
131
+ _state = FetchState.ResolveDependencies;
132
+ adapter = Adapter.GetSingleAdapter<IRemoteConfig>();
133
+ if (adapter == null)
134
+ {
135
+ NextState(false);
136
+ return;
137
+ }
138
+ adapter.ResolveDependencies(NextState);
55
139
  }
56
140
 
57
- public static Task FetchAndActivate()
141
+ static void CheckInternet()
58
142
  {
59
- if (AdapterNotReady()) return Task.FromException(new Exception("Unable to fetch and activate remote config"));
60
- return remoteConfigAdapter.FetchAndActivate();
143
+ _state = FetchState.CheckInternet;
144
+ NextState(Application.internetReachability != NetworkReachability.NotReachable);
145
+ }
146
+
147
+ static void Fetch()
148
+ {
149
+ _state = FetchState.Fetch;
150
+ adapter.FetchConfig(HasCache, (isSuccess, result) =>
151
+ {
152
+ if (!isSuccess)
153
+ {
154
+ NextState(false);
155
+ return;
156
+ }
157
+
158
+ dictConfig = result;
159
+ Source = RemoteConfigSource.Internet;
160
+ Log("[RemoteConfig] Load from the internet");
161
+ NextState(true);
162
+ });
163
+ }
164
+
165
+ static void SaveCache()
166
+ {
167
+ _state = FetchState.SaveCache;
168
+ StringBuilder sb = new StringBuilder();
169
+ foreach (var c in dictConfig)
170
+ {
171
+ sb.AppendLine($"{c.Key}\t{c.Value}");
172
+ }
173
+
174
+ var filePath = FileUtils.GetPath(fileName);
175
+ FileUtils.Save(filePath, sb.ToString());
176
+ Log($"[RemoteConfig] Saved remote config to {filePath}");
177
+ NextState();
178
+ }
179
+
180
+ static void LoadCache()
181
+ {
182
+ _state = FetchState.LoadCache;
183
+
184
+ if (!HasCache)
185
+ {
186
+ NextState(false);
187
+ return;
188
+ }
189
+
190
+ try
191
+ {
192
+ dictConfig.Clear();
193
+ using (StreamReader sr = new StreamReader(FileUtils.GetPath(fileName)))
194
+ {
195
+ string line;
196
+ int lineIdx = 0;
197
+ while ((line = sr.ReadLine()) != null)
198
+ {
199
+ lineIdx++;
200
+ var idx = line.IndexOf('\t');
201
+ if (idx == -1)
202
+ {
203
+ LogWarning($"[RemoteConfig] Cannot get (key, value) at line {lineIdx} of cache");
204
+ continue;
205
+ }
206
+ string key = line.Substring(0, idx);
207
+ string value = line.Substring(idx + 1);
208
+ dictConfig.Add(key, value);
209
+ }
210
+ }
211
+ Source = RemoteConfigSource.Cache;
212
+ Log("[RemoteConfig] Load from cache");
213
+ }
214
+ catch (Exception ex)
215
+ {
216
+ LogWarning($"[RemoteConfig] Error on LoadCache: {ex.Message}");
217
+ _cacheExisted = false;
218
+ NextState(false);
219
+ return;
220
+ }
221
+
222
+ NextState(true);
61
223
  }
62
224
 
63
- public static bool GetBool(string key)
225
+ static void LoadDefaultFile()
64
226
  {
65
- if (AdapterNotReady()) return false;
66
- return remoteConfigAdapter.GetBool(key);
227
+ _state = FetchState.LoadDefaultFile;
228
+
229
+ var defaultConfigFile = Resources.Load<TextAsset>(defaultConfigFileName);
230
+ if (defaultConfigFile == null)
231
+ {
232
+ NextState(false);
233
+ return;
234
+ }
235
+
236
+ dictConfig = JsonToDictionary(defaultConfigFile.text);
237
+
238
+ Source = RemoteConfigSource.DefaultFile;
239
+ Log("[RemoteConfig] Load from default file");
240
+ NextState(true);
67
241
  }
68
242
 
69
- public static double GetDouble(string key)
243
+ static void LoadDefaultAsset()
70
244
  {
71
- if (AdapterNotReady()) return 0;
72
- return remoteConfigAdapter.GetDouble(key);
245
+ _state = FetchState.LoadDefaultAsset;
246
+
247
+ var defaultValue = ((AdapterContext)adapter).GetAdapterConfig<RemoteConfigConfig>().defaultValue;
248
+
249
+ if (defaultValue.Length == 0)
250
+ {
251
+ NextState(false);
252
+ return;
253
+ }
254
+
255
+ foreach (var item in defaultValue)
256
+ {
257
+ dictConfig.Add(item.key, item.value);
258
+ }
259
+ Source = RemoteConfigSource.DefaultAsset;
260
+ Log("[RemoteConfig] Load from default asset");
261
+ NextState(true);
73
262
  }
74
263
 
75
- public static long GetLong(string key)
264
+ static void SetDone()
76
265
  {
77
- if (AdapterNotReady()) return 0;
78
- return remoteConfigAdapter.GetLong(key);
266
+ _state = FetchState.Success;
267
+ onAdapterInitCompleteCallback(true);
79
268
  }
80
269
 
81
- public static string GetString(string key)
270
+ static void SetFail()
82
271
  {
83
- if (AdapterNotReady()) return "";
84
- return remoteConfigAdapter.GetString(key);
272
+ _state = FetchState.Fail;
273
+ onAdapterInitCompleteCallback(false);
85
274
  }
86
- }
87
275
 
88
- public partial class RemoteConfig //Internal
89
- {
90
- internal static bool AdapterNotReady()
276
+ static Dictionary<string, string> JsonToDictionary(string json)
91
277
  {
92
- if (remoteConfigAdapter == null)
278
+ var dictResult = new Dictionary<string, string>();
279
+ string[] lines = json.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
280
+ for (int i = 0; i < lines.Length; i++)
93
281
  {
94
- LogWarning("Remote config adapter is not ready");
95
- return true;
282
+ int idx = lines[i].IndexOf(':');
283
+ if (idx < 0)
284
+ {
285
+ continue;
286
+ }
287
+ string key = lines[i].Substring(0, idx - 1).Trim().Trim('"');
288
+ string value = "";
289
+ if (idx == lines.Length - 1)
290
+ {
291
+ value = lines[i].Substring(idx + 1).Trim().Trim('"');
292
+ }
293
+ else
294
+ {
295
+ value = lines[i].Substring(idx + 1).Trim();
296
+ value = value.Substring(1, value.Length - 3);
297
+ }
298
+ dictResult[key] = value;
96
299
  }
97
- return false;
300
+ return dictResult;
301
+ }
302
+ }
303
+ }
304
+
305
+ public static class RemoteConfigExtension
306
+ {
307
+ public static void InitRemoteConfigModule(this IRemoteConfig ap, Action<bool> onCompleteCallback)
308
+ {
309
+ if (AmaGDK.RemoteConfig.State != AmaGDK.RemoteConfig.FetchState.None)
310
+ {
311
+ LogWarning($"[RemoteConfig] Current state {AmaGDK.RemoteConfig.State.ToString()}\n" +
312
+ $"Cannot start to initialize");
313
+ return;
98
314
  }
315
+ AmaGDK.RemoteConfig.onAdapterInitCompleteCallback = onCompleteCallback;
316
+ AmaGDK.RemoteConfig.NextState();
99
317
  }
100
318
  }
101
319
  }
102
320
 
103
321
  namespace Amanotes.Core.Internal
104
322
  {
105
- public interface IRemoteConfig
323
+ [Serializable]
324
+ public class RemoteConfigConfig
325
+ {
326
+ public KeyValue[] defaultValue;
327
+ public float firstFetchTimeOutInSeconds = 10;
328
+ public float defaultTimeOutInSeconds = 3;
329
+ }
330
+
331
+ [Serializable]
332
+ public class KeyValue
106
333
  {
107
- Task Fetch();
108
- Task Activate();
109
- Task FetchAndActivate();
110
- Task SetDefault(IDictionary<string, object> config);
111
- bool GetBool(string key);
112
- double GetDouble(string key);
113
- long GetLong(string key);
114
- string GetString(string key);
334
+ public string key;
335
+ public string value;
336
+ }
337
+
338
+ public interface IRemoteConfig
339
+ {
340
+ void ResolveDependencies(Action<bool> onComplete);
341
+ void FetchConfig(bool isFirstTime, Action<bool, Dictionary<string, string>> onComplete);
115
342
  }
116
343
  }
@@ -16,6 +16,11 @@ namespace Amanotes.Core.Internal
16
16
  return Path.Combine(basePath, fileName);
17
17
  }
18
18
 
19
+ internal static bool Exist(string fileName)
20
+ {
21
+ return File.Exists(GetPath(fileName));
22
+ }
23
+
19
24
  internal static void Save(string fileName, string content)
20
25
  {
21
26
  if (string.IsNullOrWhiteSpace(fileName))
@@ -127,7 +132,7 @@ namespace Amanotes.Core.Internal
127
132
  {
128
133
  LogWarningOnce(path + "\n" + ex);
129
134
  }
130
- }
135
+ }
131
136
 
132
137
  private static string _basePath;
133
138
  private static string basePath
@@ -252,7 +257,7 @@ namespace Amanotes.Core.Internal
252
257
  return DictionaryToJson(new Dictionary<string, object>() { { key, value } });
253
258
  }
254
259
 
255
- public static string DictionaryToJson(IDictionary inputDict, bool format = false)
260
+ public static string DictionaryToJson(IDictionary inputDict, bool format = false, bool checkJsonInString = true)
256
261
  {
257
262
  if (inputDict == null)
258
263
  return "{}";
@@ -276,7 +281,7 @@ namespace Amanotes.Core.Internal
276
281
  jsonSb.Append(",");
277
282
 
278
283
  jsonSb.AppendFormat("{0}\"{1}\":", format ? "\n" : "", key);
279
- AppendJsonValue(ref jsonSb, key, value, format);
284
+ AppendJsonValue(ref jsonSb, key, value, format, checkJsonInString);
280
285
 
281
286
  }
282
287
 
@@ -299,7 +304,7 @@ namespace Amanotes.Core.Internal
299
304
 
300
305
  if (format)
301
306
  jsonSb.AppendLine();
302
- AppendJsonValue(ref jsonSb, key, item, format);
307
+ AppendJsonValue(ref jsonSb, key, item, format, false);
303
308
  }
304
309
 
305
310
  if (format)
@@ -309,36 +314,60 @@ namespace Amanotes.Core.Internal
309
314
  jsonSb.Append("]");
310
315
  }
311
316
 
312
- private static void AppendJsonValue(ref StringBuilder jsonSb, string key, object value, bool format)
317
+ private static void AppendJsonValue(ref StringBuilder jsonSb, string key, object value, bool format, bool checkJsonInString)
313
318
  {
314
319
  if (value == null)
315
320
  {
316
321
  jsonSb.Append("null");
322
+ return;
317
323
  }
324
+
318
325
  if (value is string)
319
326
  {
327
+ string s = value.ToString();
328
+ if (checkJsonInString)
329
+ {
330
+ if (s.StartsWith("{") && s.EndsWith("}"))
331
+ {
332
+ jsonSb.Append(s);
333
+ return;
334
+ }
335
+ if (s.StartsWith("[") && s.EndsWith("]"))
336
+ {
337
+ jsonSb.Append(s);
338
+ return;
339
+ }
340
+ }
341
+
320
342
  jsonSb.Append($"\"{value}\"");
343
+ return;
321
344
  }
322
- else if (value is int || value is float || value is double || value is long)
345
+
346
+ if (value is int || value is float || value is double || value is long)
323
347
  {
324
348
  jsonSb.Append($"{value}");
349
+ return;
325
350
  }
326
- else if (value is bool)
351
+
352
+ if (value is bool)
327
353
  {
328
354
  jsonSb.Append((bool)value ? "true" : "false");
355
+ return;
329
356
  }
330
- else if (value is IDictionary)
357
+
358
+ if (value is IDictionary)
331
359
  {
332
360
  jsonSb.Append($"{DictionaryToJson((IDictionary)value, format)}");
361
+ return;
333
362
  }
334
- else if (value is IList || value is Array)
363
+
364
+ if (value is IList || value is Array)
335
365
  {
336
366
  GetJsonIListValue(ref jsonSb, key, (IList)value, format);
367
+ return;
337
368
  }
338
- else
339
- {
340
- jsonSb.Append($"{JsonUtility.ToJson(value, format)}");
341
- }
369
+
370
+ jsonSb.Append($"{JsonUtility.ToJson(value, format)}");
342
371
  }
343
372
 
344
373
  //public static T[] FromJsonToArray<T>(string json)
@@ -57,9 +57,8 @@ namespace Amanotes.Core.Internal
57
57
  {"api-token", requestHeader}
58
58
  });
59
59
  yield return SendWebRequest();
60
-
61
- var httpError = result == Result.ConnectionError || result == Result.ProtocolError;
62
- if (httpError)
60
+
61
+ if (!string.IsNullOrEmpty(error))
63
62
  {
64
63
  LogWarning($"{url} returned {responseCode}: {error}");
65
64
  yield break;
@@ -117,16 +116,14 @@ namespace Amanotes.Core.Internal
117
116
  webRequest.downloadHandler = new DownloadHandlerBuffer();
118
117
  yield return webRequest.SendWebRequest();
119
118
 
120
- if (webRequest.result != UnityWebRequest.Result.Success)
119
+ if (!string.IsNullOrEmpty(webRequest.error))
121
120
  {
122
- onComplete?.Invoke(false, webRequest.error);
123
-
121
+ onComplete?.Invoke(false, webRequest.error);
124
122
  }
125
123
  else
126
124
  {
127
- onComplete?.Invoke(true, webRequest.downloadHandler.text);
128
- }
129
- yield return null;
125
+ onComplete?.Invoke(true, webRequest.downloadHandler.text);
126
+ }
130
127
  }
131
128
  }
132
129
  }
package/Runtime/AmaGDK.cs CHANGED
@@ -12,7 +12,7 @@ namespace Amanotes.Core
12
12
  {
13
13
  public partial class AmaGDK : MonoBehaviour
14
14
  {
15
- public const string VERSION = "0.1.19";
15
+ public const string VERSION = "0.1.21";
16
16
 
17
17
  internal static AmaGDK _instance;
18
18
  internal static event Action _frameUpdate;
@@ -88,21 +88,22 @@ namespace Amanotes.Core
88
88
  {
89
89
  Log($"Initing {adapter.adapterId} --> initOrder: {adapter.initOrder}");
90
90
  adapter.Init();
91
+ time = 0;
91
92
 
92
93
  while (!adapter.IsReady)
93
94
  {
94
95
  time += Time.deltaTime;
95
96
  yield return null;
96
97
  if (time <= timeout) continue;
97
- LogWarningOnce($"{adapter.adapterId} init time out: {timeout}");
98
+ LogWarning($"{adapter.adapterId} init time out: {timeout}");
99
+ break;
98
100
  }
99
101
 
100
- Log($"Adapter {adapter.adapterId} inited!");
102
+ Log(string.Format("Adapter {0} {1}", adapter.adapterId, adapter.IsReady ? "inited!" : "is not ready!"));
101
103
  }
102
104
 
103
105
  // Init modules (Adapter managers)
104
106
  Analytics.Init();
105
- RemoteConfig.Init();
106
107
  //Ads.Init();
107
108
 
108
109
  _status = Status.Ready;