com.amanotes.gdk 0.1.20 → 0.2.1

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 (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/Editor/AmaGDKEditor.cs +91 -46
  3. package/Editor/AmaGDKManager.cs +26 -27
  4. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +133 -103
  5. package/Editor/Utils/AmaGDKEditor.GUI.cs +54 -51
  6. package/Editor/Utils/AmaGDKEditor.Utils.cs +2 -3
  7. package/Packages/AmaGDKConfig.unitypackage +0 -0
  8. package/Packages/AmaGDKExample.unitypackage +0 -0
  9. package/Packages/AmaGDKTest.unitypackage +0 -0
  10. package/Packages/AmaPassport.ATTSupport.unitypackage +0 -0
  11. package/{Samples~/Example/AmaGDKExample.unity.meta → Packages/AmaPassport.ATTSupport.unitypackage.meta} +1 -1
  12. package/Packages/AmaPassport.AdvertisingID.unitypackage +0 -0
  13. package/{Sample~/Example/AmaGDKExample.unity.meta → Packages/AmaPassport.AdvertisingID.unitypackage.meta} +1 -1
  14. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  15. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  16. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  17. package/{Runtime/AmaPassport/Plugins.meta → Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta} +1 -2
  18. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  19. package/Runtime/AmaGDK.Adapters.cs +30 -12
  20. package/Runtime/AmaGDK.Ads.cs +520 -162
  21. package/Runtime/{AmaPassport/AmaGDK.AmaPassport.cs → AmaGDK.AmaPassport.cs} +36 -47
  22. package/Runtime/{AmaPassport/AmaGDK.AmaPassport.cs.meta → AmaGDK.AmaPassport.cs.meta} +1 -1
  23. package/Runtime/AmaGDK.Analytics.cs +78 -89
  24. package/Runtime/AmaGDK.Config.cs +23 -19
  25. package/Runtime/AmaGDK.Internal.SemVer.cs +11 -29
  26. package/Runtime/AmaGDK.Internal.cs +17 -11
  27. package/Runtime/AmaGDK.RemoteConfig.cs +352 -0
  28. package/Runtime/{AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs.meta → AmaGDK.RemoteConfig.cs.meta} +1 -1
  29. package/Runtime/AmaGDK.UserProfile.cs +5 -8
  30. package/Runtime/AmaGDK.Utils.cs +79 -60
  31. package/Runtime/AmaGDK.WebUtils.cs +45 -48
  32. package/Runtime/AmaGDK.cs +74 -22
  33. package/Runtime/AssemblyInfo.cs +0 -1
  34. package/package.json +1 -1
  35. package/Packages/AppsflyerAdapter_v6.5.4.unitypackage +0 -0
  36. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java +0 -7
  37. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdCallback.java.meta +0 -32
  38. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.cs +0 -96
  39. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java +0 -79
  40. package/Runtime/AmaPassport/Plugins/Android/AdvertisingIdFetcher.java.meta +0 -32
  41. package/Runtime/AmaPassport/Plugins/Android.meta +0 -8
  42. package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs +0 -59
  43. package/Runtime/AmaPassport/Plugins/iOS/KeyChain.cs.meta +0 -11
  44. package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm +0 -52
  45. package/Runtime/AmaPassport/Plugins/iOS/KeyChainPlugin.mm.meta +0 -33
  46. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h +0 -281
  47. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.h.meta +0 -33
  48. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m +0 -1393
  49. package/Runtime/AmaPassport/Plugins/iOS/UICKeyChainStore.m.meta +0 -33
  50. package/Runtime/AmaPassport/Plugins/iOS.meta +0 -8
  51. package/Runtime/AmaPassport.meta +0 -8
  52. package/Samples~/Example/AmaGDKExample.cs +0 -87
  53. package/Samples~/Example/AmaGDKExample.cs.meta +0 -11
  54. package/Samples~/Example/AmaGDKExample.unity +0 -3114
  55. package/Sample~/Example/AmaGDKExample.cs +0 -87
  56. package/Sample~/Example/AmaGDKExample.cs.meta +0 -11
  57. package/Sample~/Example/AmaGDKExample.unity +0 -3114
  58. /package/Packages/{AppsflyerAdapter_v6.5.4.unitypackage.meta → AppsFlyerAdapter_v6.5.4.unitypackage.meta} +0 -0
@@ -4,23 +4,42 @@ using System.Collections.Generic;
4
4
  using System.IO;
5
5
  using System.Text;
6
6
  using UnityEngine;
7
-
8
7
  using static Amanotes.Core.Internal.Logging;
9
8
 
10
9
  namespace Amanotes.Core.Internal
11
10
  {
12
11
  internal class FileUtils
13
12
  {
13
+
14
+ private static string _basePath;
15
+ private static string basePath
16
+ {
17
+ get
18
+ {
19
+ if (!string.IsNullOrEmpty(_basePath)) return _basePath;
20
+ _basePath = Application.isEditor
21
+ ? Path.Combine(Directory.GetCurrentDirectory(), "Library", "AmaGDK")
22
+ : Path.Combine(Application.persistentDataPath, "AmaGDK");
23
+
24
+ if (!Directory.Exists(_basePath)) Directory.CreateDirectory(_basePath);
25
+ return _basePath;
26
+ }
27
+ }
14
28
  internal static string GetPath(string fileName)
15
29
  {
16
30
  return Path.Combine(basePath, fileName);
17
31
  }
18
32
 
33
+ internal static bool Exist(string fileName)
34
+ {
35
+ return File.Exists(GetPath(fileName));
36
+ }
37
+
19
38
  internal static void Save(string fileName, string content)
20
39
  {
21
40
  if (string.IsNullOrWhiteSpace(fileName))
22
41
  {
23
- LogWarningOnce($"File name must be not null or empty");
42
+ LogWarningOnce("File name must be not null or empty");
24
43
  return;
25
44
  }
26
45
 
@@ -45,7 +64,7 @@ namespace Amanotes.Core.Internal
45
64
  {
46
65
  if (string.IsNullOrWhiteSpace(fileName))
47
66
  {
48
- LogWarningOnce($"File name must be not null or empty");
67
+ LogWarningOnce("File name must be not null or empty");
49
68
  return;
50
69
  }
51
70
 
@@ -62,14 +81,14 @@ namespace Amanotes.Core.Internal
62
81
  catch (Exception ex)
63
82
  {
64
83
  LogWarningOnce(path + "\n" + ex);
65
- }
84
+ }
66
85
  }
67
86
 
68
87
  internal static void SaveAppend(string fileName, string content)
69
88
  {
70
89
  if (string.IsNullOrWhiteSpace(fileName))
71
90
  {
72
- LogWarningOnce($"File name must be not null or empty");
91
+ LogWarningOnce("File name must be not null or empty");
73
92
  return;
74
93
  }
75
94
 
@@ -87,15 +106,15 @@ namespace Amanotes.Core.Internal
87
106
  {
88
107
  LogWarningOnce(path + "\n" + ex);
89
108
  }
90
- }
109
+ }
91
110
 
92
111
  internal static string Load(string fileName)
93
112
  {
94
- string content = "";
113
+ var content = "";
95
114
 
96
115
  if (string.IsNullOrWhiteSpace(fileName))
97
116
  {
98
- LogWarningOnce($"File name must be not null or empty");
117
+ LogWarningOnce("File name must be not null or empty");
99
118
  return content;
100
119
  }
101
120
 
@@ -128,28 +147,13 @@ namespace Amanotes.Core.Internal
128
147
  LogWarningOnce(path + "\n" + ex);
129
148
  }
130
149
  }
131
-
132
- private static string _basePath;
133
- private static string basePath
134
- {
135
- get
136
- {
137
- if (!string.IsNullOrEmpty(_basePath)) return _basePath;
138
- _basePath = Application.isEditor
139
- ? Path.Combine(Directory.GetCurrentDirectory(), "Library", "AmaGDK")
140
- : Path.Combine(Application.persistentDataPath, "AmaGDK");
141
-
142
- if (!Directory.Exists(_basePath)) Directory.CreateDirectory(_basePath);
143
- return _basePath;
144
- }
145
- }
146
150
  }
147
151
 
148
152
  public class ActionQueue
149
153
  {
150
- private Queue<Action<Action>> queue;
151
- private bool isProcessing = false;
152
- private Action onComplete;
154
+ private bool isProcessing;
155
+ private readonly Action onComplete;
156
+ private readonly Queue<Action<Action>> queue;
153
157
 
154
158
  public ActionQueue(Action onComplete)
155
159
  {
@@ -165,7 +169,7 @@ namespace Amanotes.Core.Internal
165
169
  return;
166
170
  }
167
171
 
168
- foreach (var action in actions)
172
+ foreach (Action<Action> action in actions)
169
173
  {
170
174
  if (action == null) continue;
171
175
  queue.Enqueue(action);
@@ -174,8 +178,7 @@ namespace Amanotes.Core.Internal
174
178
 
175
179
  private void ProcessQueue()
176
180
  {
177
- if (isProcessing)
178
- return;
181
+ if (isProcessing) return;
179
182
  if (queue.Count == 0)
180
183
  {
181
184
  onComplete?.Invoke();
@@ -194,8 +197,7 @@ namespace Amanotes.Core.Internal
194
197
  }
195
198
  }
196
199
 
197
- if(nextAction == null)
198
- onComplete?.Invoke();
200
+ if (nextAction == null) onComplete?.Invoke();
199
201
  }
200
202
 
201
203
  public void StartQueue()
@@ -222,7 +224,7 @@ namespace Amanotes.Core.Internal
222
224
  instance = result;
223
225
  }
224
226
  string fileName = instance.GetType().Name;
225
- var json = FileUtils.Load(fileName);
227
+ string json = FileUtils.Load(fileName);
226
228
  JsonUtility.FromJsonOverwrite(json, instance);
227
229
  return instance;
228
230
  }
@@ -230,7 +232,7 @@ namespace Amanotes.Core.Internal
230
232
  public static void SaveJsonToFile<T>(this T instance) where T : IJsonFile
231
233
  {
232
234
  string fileName = instance.GetType().Name;
233
- var json = JsonUtility.ToJson(instance);
235
+ string json = JsonUtility.ToJson(instance);
234
236
  FileUtils.Save(fileName, json);
235
237
  }
236
238
  }
@@ -239,7 +241,7 @@ namespace Amanotes.Core.Internal
239
241
  {
240
242
  public static string TupleToJson(params (string key, object value)[] parameters)
241
243
  {
242
- Dictionary<string, object> tupleToDict = new Dictionary<string, object>();
244
+ var tupleToDict = new Dictionary<string, object>();
243
245
  foreach (var item in parameters)
244
246
  {
245
247
  tupleToDict.Add(item.key, item.value);
@@ -249,24 +251,21 @@ namespace Amanotes.Core.Internal
249
251
 
250
252
  public static string KeyValueToJson(string key, object value)
251
253
  {
252
- return DictionaryToJson(new Dictionary<string, object>() { { key, value } });
254
+ return DictionaryToJson(new Dictionary<string, object>
255
+ { { key, value } });
253
256
  }
254
257
 
255
- public static string DictionaryToJson(IDictionary inputDict, bool format = false)
258
+ public static string DictionaryToJson(IDictionary inputDict, bool format = false, bool checkJsonInString = true)
256
259
  {
257
- if (inputDict == null)
258
- return "{}";
260
+ if (inputDict == null) return "{}";
259
261
 
260
- StringBuilder jsonSb = new StringBuilder();
262
+ var jsonSb = new StringBuilder();
261
263
  jsonSb.Append("{");
262
264
  var isFirstElement = true;
263
265
 
264
266
  foreach (DictionaryEntry entry in inputDict)
265
267
  {
266
- if (entry.Key == null || string.IsNullOrEmpty(entry.Key.ToString()))
267
- {
268
- continue;
269
- }
268
+ if (entry.Key == null || string.IsNullOrEmpty(entry.Key.ToString())) continue;
270
269
  var key = entry.Key.ToString();
271
270
  var value = entry.Value;
272
271
 
@@ -276,7 +275,7 @@ namespace Amanotes.Core.Internal
276
275
  jsonSb.Append(",");
277
276
 
278
277
  jsonSb.AppendFormat("{0}\"{1}\":", format ? "\n" : "", key);
279
- AppendJsonValue(ref jsonSb, key, value, format);
278
+ AppendJsonValue(ref jsonSb, key, value, format, checkJsonInString);
280
279
 
281
280
  }
282
281
 
@@ -297,48 +296,68 @@ namespace Amanotes.Core.Internal
297
296
  else
298
297
  jsonSb.Append(",");
299
298
 
300
- if (format)
301
- jsonSb.AppendLine();
302
- AppendJsonValue(ref jsonSb, key, item, format);
299
+ if (format) jsonSb.AppendLine();
300
+ AppendJsonValue(ref jsonSb, key, item, format, false);
303
301
  }
304
302
 
305
- if (format)
306
- {
307
- jsonSb.AppendLine();
308
- }
303
+ if (format) jsonSb.AppendLine();
309
304
  jsonSb.Append("]");
310
305
  }
311
306
 
312
- private static void AppendJsonValue(ref StringBuilder jsonSb, string key, object value, bool format)
307
+ private static void AppendJsonValue(ref StringBuilder jsonSb, string key, object value, bool format, bool checkJsonInString)
313
308
  {
314
309
  if (value == null)
315
310
  {
316
311
  jsonSb.Append("null");
312
+ return;
317
313
  }
314
+
318
315
  if (value is string)
319
316
  {
317
+ var s = value.ToString();
318
+ if (checkJsonInString)
319
+ {
320
+ if (s.StartsWith("{") && s.EndsWith("}"))
321
+ {
322
+ jsonSb.Append(s);
323
+ return;
324
+ }
325
+ if (s.StartsWith("[") && s.EndsWith("]"))
326
+ {
327
+ jsonSb.Append(s);
328
+ return;
329
+ }
330
+ }
331
+
320
332
  jsonSb.Append($"\"{value}\"");
333
+ return;
321
334
  }
322
- else if (value is int || value is float || value is double || value is long)
335
+
336
+ if (value is int || value is float || value is double || value is long)
323
337
  {
324
338
  jsonSb.Append($"{value}");
339
+ return;
325
340
  }
326
- else if (value is bool)
341
+
342
+ if (value is bool)
327
343
  {
328
344
  jsonSb.Append((bool)value ? "true" : "false");
345
+ return;
329
346
  }
330
- else if (value is IDictionary)
347
+
348
+ if (value is IDictionary)
331
349
  {
332
350
  jsonSb.Append($"{DictionaryToJson((IDictionary)value, format)}");
351
+ return;
333
352
  }
334
- else if (value is IList || value is Array)
353
+
354
+ if (value is IList || value is Array)
335
355
  {
336
356
  GetJsonIListValue(ref jsonSb, key, (IList)value, format);
357
+ return;
337
358
  }
338
- else
339
- {
340
- jsonSb.Append($"{JsonUtility.ToJson(value, format)}");
341
- }
359
+
360
+ jsonSb.Append($"{JsonUtility.ToJson(value, format)}");
342
361
  }
343
362
 
344
363
  //public static T[] FromJsonToArray<T>(string json)
@@ -1,34 +1,20 @@
1
- using System.Collections;
2
- using UnityEngine.Networking;
3
- using System;
1
+ using System;
2
+ using System.Collections;
4
3
  using System.Collections.Generic;
4
+ using System.Text;
5
5
  using UnityEngine;
6
+ using UnityEngine.Networking;
6
7
  using static Amanotes.Core.Internal.Logging;
7
8
 
8
9
  namespace Amanotes.Core.Internal
9
10
  {
10
11
  public class JsonWebRequest<T> : UnityWebRequest where T : class
11
12
  {
12
-
13
- [Serializable]
14
- internal class ResponseError
15
- {
16
- public string error;
17
- public string message;
18
- public string statusCode;
19
- }
20
-
21
- [Serializable]
22
- internal class ResponseT
23
- {
24
- public T data;
25
- public ResponseError error = null;
26
- }
27
-
28
- private string requestJson;
29
- private string requestHeader;
30
13
  public T data;
31
14
  public bool isResponseError;
15
+ private readonly string requestHeader;
16
+
17
+ private readonly string requestJson;
32
18
 
33
19
  public JsonWebRequest(string url, string json, string header = "") : base(url, "POST")
34
20
  {
@@ -47,24 +33,23 @@ namespace Amanotes.Core.Internal
47
33
 
48
34
  public new IEnumerator Send()
49
35
  {
50
- byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(requestJson);
36
+ byte[] bodyRaw = Encoding.UTF8.GetBytes(requestJson);
51
37
  uploadHandler = new UploadHandlerRaw(bodyRaw);
52
38
  downloadHandler = new DownloadHandlerBuffer();
53
39
  SetRequestHeader(new Dictionary<string, string>
54
40
  {
55
- {"Authorization", $"bearer {requestHeader}"},
56
- {"Content-Type", "application/json"},
57
- {"api-token", requestHeader}
41
+ { "Authorization", $"bearer {requestHeader}" },
42
+ { "Content-Type", "application/json" },
43
+ { "api-token", requestHeader }
58
44
  });
59
45
  yield return SendWebRequest();
60
-
61
- var httpError = result == Result.ConnectionError || result == Result.ProtocolError;
62
- if (httpError)
46
+
47
+ if (!string.IsNullOrEmpty(error))
63
48
  {
64
49
  LogWarning($"{url} returned {responseCode}: {error}");
65
50
  yield break;
66
51
  }
67
-
52
+
68
53
  try
69
54
  {
70
55
  string result = downloadHandler.text;
@@ -88,22 +73,36 @@ namespace Amanotes.Core.Internal
88
73
  {
89
74
  LogWarning($"Error parsing {typeof(T)}: {ex.Message}\n");
90
75
  isResponseError = true;
91
- yield break;
92
76
  }
93
77
  }
78
+
79
+ [Serializable]
80
+ internal class ResponseError
81
+ {
82
+ public string error;
83
+ public string message;
84
+ public string statusCode;
85
+ }
86
+
87
+ [Serializable]
88
+ internal class ResponseT
89
+ {
90
+ public T data;
91
+ public ResponseError error;
92
+ }
94
93
  }
95
94
 
96
95
 
97
96
  internal class WebUtils
98
97
  {
99
- public static Coroutine PostJson(string url, string jsonData, Action<bool, string> onComplete = null, Dictionary<string, string> headers = null)
100
- {
101
- return AmaGDK._instance.StartCoroutine(PostJsonCoroutine(url, jsonData, onComplete, headers));
102
- }
98
+ public static Coroutine PostJson(string url, string jsonData, Action<bool, string> onComplete = null, Dictionary<string, string> headers = null)
99
+ {
100
+ return AmaGDK._instance.StartCoroutine(PostJsonCoroutine(url, jsonData, onComplete, headers));
101
+ }
103
102
 
104
- static IEnumerator PostJsonCoroutine(string url, string jsonData, Action<bool, string> onComplete = null, Dictionary<string, string> headers = null)
103
+ private static IEnumerator PostJsonCoroutine(string url, string jsonData, Action<bool, string> onComplete = null, Dictionary<string, string> headers = null)
105
104
  {
106
- UnityWebRequest webRequest = new UnityWebRequest(url, "POST");
105
+ var webRequest = new UnityWebRequest(url, "POST");
107
106
  if (headers != null)
108
107
  {
109
108
  foreach (KeyValuePair<string, string> kvp in headers)
@@ -112,21 +111,19 @@ namespace Amanotes.Core.Internal
112
111
  }
113
112
  }
114
113
 
115
- byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonData);
114
+ byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData);
116
115
  webRequest.uploadHandler = new UploadHandlerRaw(bodyRaw);
117
116
  webRequest.downloadHandler = new DownloadHandlerBuffer();
118
117
  yield return webRequest.SendWebRequest();
119
118
 
120
- if (webRequest.result != UnityWebRequest.Result.Success)
121
- {
122
- onComplete?.Invoke(false, webRequest.error);
123
-
124
- }
125
- else
126
- {
127
- onComplete?.Invoke(true, webRequest.downloadHandler.text);
128
- }
129
- yield return null;
119
+ if (!string.IsNullOrEmpty(webRequest.error))
120
+ {
121
+ onComplete?.Invoke(false, webRequest.error);
122
+ }
123
+ else
124
+ {
125
+ onComplete?.Invoke(true, webRequest.downloadHandler.text);
126
+ }
130
127
  }
131
128
  }
132
- }
129
+ }
package/Runtime/AmaGDK.cs CHANGED
@@ -2,9 +2,6 @@ using System;
2
2
  using System.Collections;
3
3
  using Amanotes.Core.Internal;
4
4
  using UnityEngine;
5
-
6
- using ConfigAsset = Amanotes.Core.Internal.ConfigAsset;
7
- using Status = Amanotes.Core.Internal.Status;
8
5
  using static Amanotes.Core.Internal.Logging;
9
6
  using static Amanotes.Core.Internal.Messsage;
10
7
 
@@ -12,10 +9,9 @@ namespace Amanotes.Core
12
9
  {
13
10
  public partial class AmaGDK : MonoBehaviour
14
11
  {
15
- public const string VERSION = "0.1.20";
12
+ public const string VERSION = "0.2.1";
16
13
 
17
14
  internal static AmaGDK _instance;
18
- internal static event Action _frameUpdate;
19
15
  internal static Status _status = Status.None;
20
16
  internal static Action _onReadyCallback;
21
17
  internal static bool _allowInit = false;
@@ -28,12 +24,13 @@ namespace Amanotes.Core
28
24
  {
29
25
  if (_config != null) return _config;
30
26
  _config = Resources.Load<ConfigAsset>("AmaGDKConfig");
27
+
31
28
  // if (_config == null) LogWarningOnce(CONFIG_NOT_FOUND);
32
29
  return _config;
33
30
  }
34
31
  }
35
32
 
36
- void Awake()
33
+ private void Awake()
37
34
  {
38
35
  if (_instance != null && _instance != this)
39
36
  {
@@ -42,10 +39,7 @@ namespace Amanotes.Core
42
39
  return;
43
40
  }
44
41
 
45
- if (_instance != null)
46
- {
47
- LogWarning("Should never be here!");
48
- }
42
+ if (_instance != null) LogWarning("Should never be here!");
49
43
 
50
44
  _instance = this;
51
45
  DontDestroyOnLoad(this);
@@ -54,7 +48,7 @@ namespace Amanotes.Core
54
48
  _allowInit = _allowInit || autoInit;
55
49
  StartCoroutine(InitRoutine());
56
50
  }
57
-
51
+
58
52
  IEnumerator InitRoutine()
59
53
  {
60
54
  if (Config == null)
@@ -84,24 +78,29 @@ namespace Amanotes.Core
84
78
 
85
79
  // sort on priority
86
80
  Adapter.listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
87
- foreach (var adapter in Adapter.listAdapters)
81
+ foreach (AdapterContext adapter in Adapter.listAdapters)
88
82
  {
89
- Log($"Initing {adapter.adapterId} --> initOrder: {adapter.initOrder}");
83
+ Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder}");
90
84
  adapter.Init();
85
+ RegisterUnityCallback(adapter);
86
+
87
+ time = 0;
91
88
 
92
89
  while (!adapter.IsReady)
93
90
  {
94
91
  time += Time.deltaTime;
95
92
  yield return null;
96
93
  if (time <= timeout) continue;
97
- LogWarningOnce($"{adapter.adapterId} init time out: {timeout}");
94
+ LogWarning($"{adapter.adapterId} init time out: {timeout}");
95
+ break;
98
96
  }
99
97
 
100
- Log($"Adapter {adapter.adapterId} inited!");
98
+ Log(string.Format("Adapter {0} {1}", adapter.adapterId, adapter.IsReady ? "inited!" : "is not ready!"));
101
99
  }
102
100
 
103
101
  // Init modules (Adapter managers)
104
102
  Analytics.Init();
103
+
105
104
  //Ads.Init();
106
105
 
107
106
  _status = Status.Ready;
@@ -110,11 +109,38 @@ namespace Amanotes.Core
110
109
  Debug.Log($"[AmaGDK] {READY}");
111
110
  }
112
111
 
113
- private void Update()
112
+ void RegisterUnityCallback(AdapterContext adapter)
114
113
  {
115
- if (!isReady) return;
116
- _frameUpdate?.Invoke();
114
+ switch (adapter)
115
+ {
116
+ case IOnFrameUpdate a: {
117
+ onFrameUpdate -= a.OnFrameUpdate;
118
+ onFrameUpdate += a.OnFrameUpdate;
119
+ break;
120
+ }
121
+
122
+ case IOnApplicationPause a: {
123
+ onApplicationPause -= a.OnApplicationPause;
124
+ onApplicationPause += a.OnApplicationPause;
125
+ break;
126
+ }
127
+
128
+ case IOnApplicationFocus a:
129
+ {
130
+ applicationFocus -= a.OnApplicationFocus;
131
+ applicationFocus += a.OnApplicationFocus;
132
+ break;
133
+ }
134
+
135
+ case IOnApplicationQuit a:
136
+ {
137
+ applicationQuit -= a.OnApplicationQuit;
138
+ applicationQuit += a.OnApplicationQuit;
139
+ break;
140
+ }
141
+ }
117
142
  }
143
+
118
144
  }
119
145
 
120
146
  public partial class AmaGDK // PUBLIC APIS
@@ -149,8 +175,6 @@ namespace Amanotes.Core
149
175
  _instance = sdk.AddComponent<AmaGDK>();
150
176
  }
151
177
 
152
-
153
-
154
178
  public static void SetOnReadyCallback(Action onReady)
155
179
  {
156
180
  if (onReady == null)
@@ -161,7 +185,6 @@ namespace Amanotes.Core
161
185
  _onReadyCallback -= onReady;
162
186
  _onReadyCallback += onReady;
163
187
  }
164
-
165
188
  }
166
189
 
167
190
  public partial class AmaGDK
@@ -175,4 +198,33 @@ namespace Amanotes.Core
175
198
  public const string REVENUECAT = "RevenueCat";
176
199
  }
177
200
  }
178
- }
201
+
202
+ public partial class AmaGDK
203
+ {
204
+ internal static event Action onFrameUpdate;
205
+ internal static event Action<bool> onApplicationPause;
206
+ internal static event Action<bool> applicationFocus;
207
+ internal static event Action applicationQuit;
208
+
209
+ private void OnApplicationPause(bool pauseStatus)
210
+ {
211
+ onApplicationPause?.Invoke(pauseStatus);
212
+ }
213
+
214
+ private void OnApplicationFocus(bool hasFocus)
215
+ {
216
+ applicationFocus?.Invoke(hasFocus);
217
+ }
218
+
219
+ private void Update()
220
+ {
221
+ if (!isReady) return;
222
+ onFrameUpdate?.Invoke();
223
+ }
224
+
225
+ private void OnApplicationQuit()
226
+ {
227
+ applicationQuit?.Invoke();
228
+ }
229
+ }
230
+ }
@@ -1,5 +1,4 @@
1
1
  using System.Runtime.CompilerServices;
2
-
3
2
  [assembly: InternalsVisibleTo("AmaGDK.Test")]
4
3
 
5
4
  #if UNITY_EDITOR
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.1.20",
3
+ "version": "0.2.1",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2020.3",
@@ -1,7 +0,0 @@
1
-
2
- package com.miniit.android;
3
-
4
- public interface AdvertisingIdCallback
5
- {
6
- public void onResult(String adid);
7
- }
@@ -1,32 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: b20a41b7f3c814bbd905559d73f7d253
3
- PluginImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- iconMap: {}
7
- executionOrder: {}
8
- defineConstraints: []
9
- isPreloaded: 0
10
- isOverridable: 0
11
- isExplicitlyReferenced: 0
12
- validateReferences: 1
13
- platformData:
14
- - first:
15
- Android: Android
16
- second:
17
- enabled: 1
18
- settings: {}
19
- - first:
20
- Any:
21
- second:
22
- enabled: 0
23
- settings: {}
24
- - first:
25
- Editor: Editor
26
- second:
27
- enabled: 0
28
- settings:
29
- DefaultValueInitialized: true
30
- userData:
31
- assetBundleName:
32
- assetBundleVariant: