com.amanotes.gdk 0.2.20 → 0.2.22

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,152 +1,161 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.22 - 2023-10-11]
4
+ - Get adapter info
5
+
6
+ ## [0.2.21 - 2023-10-11]
7
+ - RevenueCat adapter v6.0.0
8
+ - Handle early Firebase call
9
+ - Fix null exception in non-subscription game
10
+ - Add log level
11
+
3
12
  ## [0.2.20 - 2023-10-05]
4
- ### Update RevenueCat 5.3.0
13
+ - Update RevenueCat 5.3.0
5
14
 
6
15
  ## [0.2.19 - 2023-09-12]
7
- ### Add `ama_device_id` to all events
16
+ - Add `ama_device_id` to all events
8
17
 
9
18
  ## [0.2.18 - 2023-09-11]
10
- ### Add dev mode switch
11
- ### Auto get SDK version
12
- ### Add in-app purchase module, RevenueCat
13
- ### Support Unity 2019.4
14
- ### Remove AmaPassport
19
+ - Add dev mode switch
20
+ - Auto get SDK version
21
+ - Add in-app purchase module, RevenueCat
22
+ - Support Unity 2019.4
23
+ - Remove AmaPassport
15
24
 
16
25
  ## [0.2.14 - 2023-08-08]
17
- ### Support multiple embed remote config and load config by id
18
- ### Clear cached remote config on new app update
19
- ### Override remote config value in editor mode
20
- ### New feature: Analytics Quality
26
+ - Support multiple embed remote config and load config by id
27
+ - Clear cached remote config on new app update
28
+ - Override remote config value in editor mode
29
+ - New feature: Analytics Quality
21
30
 
22
31
  ## [0.2.13 - 2023-07-20]
23
- ### Fix error Remote Config JSON caused by special chars (", ', \)
32
+ - Fix error Remote Config JSON caused by special chars (", ', \)
24
33
 
25
34
  ## [0.2.12 - 2023-07-07]
26
- ### Restructure GDK - symlink GDK source to unity projects
27
- ### Unity 2019 compatible - no null coalescing
28
- ### Remove redundant AmaPassport config field
29
- ### Auto request AmaId
35
+ - Restructure GDK - symlink GDK source to unity projects
36
+ - Unity 2019 compatible - no null coalescing
37
+ - Remove redundant AmaPassport config field
38
+ - Auto request AmaId
30
39
 
31
40
  ## [0.2.11 - 2023-06-29]
32
- ### SetLogCondition with EventParam
33
- ### Rename Migrated -> HasMigrated
34
- ### Fix StopShowAd
41
+ - SetLogCondition with EventParam
42
+ - Rename Migrated -> HasMigrated
43
+ - Fix StopShowAd
35
44
 
36
45
  ## [0.2.10 - 2023-06-23]
37
- ### Extra package: Project Panel
38
- ### Remote config: Allow user to enable / disable automatic default valuye updating (in play mode)
39
- ### Fix ad routine
40
- ### Expose analytics migration flag
46
+ - Extra package: Project Panel
47
+ - Remote config: Allow user to enable / disable automatic default valuye updating (in play mode)
48
+ - Fix ad routine
49
+ - Expose analytics migration flag
41
50
 
42
51
  ## [0.2.9 - 2023-06-15]
43
- ### Show total init time
44
- ### Show adapter version + status at init time
45
- ### Remove AmaGDK version in debug log
46
- ### Remove "Params" in analytics debug log
47
- ### Check "event_name" early
48
- ### Fix null exception in AmaGDKInstaller
49
- ### Add csc.rsp to enable AMAGDK_DEV
50
- ### Update Ads module
52
+ - Show total init time
53
+ - Show adapter version + status at init time
54
+ - Remove AmaGDK version in debug log
55
+ - Remove "Params" in analytics debug log
56
+ - Check "event_name" early
57
+ - Fix null exception in AmaGDKInstaller
58
+ - Add csc.rsp to enable AMAGDK_DEV
59
+ - Update Ads module
51
60
 
52
61
  ## [0.2.8 - 2023-06-12]
53
- ### Mute Appsflyer's init log on Editor
54
- ### Clear analytics log in adapters
55
- ### Check null event params before calling AddParam()
56
- ### Export AmaPassport info
62
+ - Mute Appsflyer's init log on Editor
63
+ - Clear analytics log in adapters
64
+ - Check null event params before calling AddParam()
65
+ - Export AmaPassport info
57
66
 
58
67
  ## [0.2.7 - 2023-06-09]
59
- ### Fix log single adapter
68
+ - Fix log single adapter
60
69
 
61
70
  ## [0.2.6 - 2023-06-08]
62
- ### Update AmaPassport
63
- ### Fix JSON parse in RemoteConfig
64
- ### Ads adds interstitial callbacks
65
- ### Clean & export AmaGDK Installer
71
+ - Update AmaPassport
72
+ - Fix JSON parse in RemoteConfig
73
+ - Ads adds interstitial callbacks
74
+ - Clean & export AmaGDK Installer
66
75
 
67
76
  ## [0.2.5 - 2023-06-07]
68
- ### Remove ATT dependency package
77
+ - Remove ATT dependency package
69
78
 
70
79
  ## [0.2.4 - 2023-06-07]
71
- ### Hotfix Ads module
72
- ### Update Analytics unit tests
80
+ - Hotfix Ads module
81
+ - Update Analytics unit tests
73
82
 
74
83
  ## [0.2.3 - 2023-06-06]
75
- ### Refactor Ads module, support ironSource
76
- ### Refactor AmaPassport
77
- ### Refactor AmaGDK structure
78
- ### Add callback when RemoteConfig module completes fetching
84
+ - Refactor Ads module, support ironSource
85
+ - Refactor AmaPassport
86
+ - Refactor AmaGDK structure
87
+ - Add callback when RemoteConfig module completes fetching
79
88
 
80
89
  ## [0.1.20 - 2023-04-20]
81
- ### Refactor Adapter architure to support reading adapter config from Core
82
- ### Add session stat for Analytics module
83
- ### Unit test for Json parser and Analytics module
90
+ - Refactor Adapter architure to support reading adapter config from Core
91
+ - Add session stat for Analytics module
92
+ - Unit test for Json parser and Analytics module
84
93
 
85
94
  ## [0.1.19 - 2023-04-11]
86
- ### Move AmaGDKTest out of AmaGDKCore
95
+ - Move AmaGDKTest out of AmaGDKCore
87
96
 
88
97
  ## [0.1.18 - 2023-03-27]
89
- ### Fix AmaGDK's autoInit saving issue
98
+ - Fix AmaGDK's autoInit saving issue
90
99
 
91
100
  ## [0.1.17 - 2023-03-13]
92
- ### Release AmaGDK v0.1.17
93
- ### Rename Analytics APIs
101
+ - Release AmaGDK v0.1.17
102
+ - Rename Analytics APIs
94
103
 
95
104
  ## [0.1.16 - 2023-03-10]
96
- ### Release AmaGDK v0.1.16
97
- ### SemVer supports 4 parts
98
- ### Analytics supports EventConfig
105
+ - Release AmaGDK v0.1.16
106
+ - SemVer supports 4 parts
107
+ - Analytics supports EventConfig
99
108
 
100
109
  ## [0.1.15 - 2023-03-06]
101
- ### Release AmaGDK v0.1.15
102
- ### Fix null exception in VersionExtractor
103
- ### Warn unhandle platform in Appsflyer initialization
104
- ### Allow dev to SetPermittedEvents and SetForbiddenEvents to the adapter config
110
+ - Release AmaGDK v0.1.15
111
+ - Fix null exception in VersionExtractor
112
+ - Warn unhandle platform in Appsflyer initialization
113
+ - Allow dev to SetPermittedEvents and SetForbiddenEvents to the adapter config
105
114
 
106
115
  ## [0.1.14 - 2023-03-02]
107
- ### Release AmaGDK v0.1.14
116
+ - Release AmaGDK v0.1.14
108
117
 
109
118
  ## [0.1.13 - 2023-03-01]
110
- ### Release AmaGDK v0.1.13
111
- ### Fix Semver parser
119
+ - Release AmaGDK v0.1.13
120
+ - Fix Semver parser
112
121
 
113
122
  ## [0.1.12 - 2023-03-01]
114
- ### Release AmaGDK v0.1.12
115
- ### Prioritize analytics instant config over the base config
116
- ### Public common config
123
+ - Release AmaGDK v0.1.12
124
+ - Prioritize analytics instant config over the base config
125
+ - Public common config
117
126
 
118
127
  ## [0.1.11 - 2023-02-28]
119
- ### Release AmaGDK v0.1.11
120
- ### Auto start and log Appsflyer open session
121
- ### Add analytics adapter base config
122
- ### Analytics: count by session
123
- ### Export example scene
124
- ### Add AmaGDKManager
125
- ### Refactor Adapter to support for init order configuration
128
+ - Release AmaGDK v0.1.11
129
+ - Auto start and log Appsflyer open session
130
+ - Add analytics adapter base config
131
+ - Analytics: count by session
132
+ - Export example scene
133
+ - Add AmaGDKManager
134
+ - Refactor Adapter to support for init order configuration
126
135
 
127
136
  ## [0.1.10 - 2023-02-17]
128
- ### Release AmaGDK v0.1.10
137
+ - Release AmaGDK v0.1.10
129
138
 
130
139
  ## [0.1.9 - 2023-02-15]
131
- ### Release AmaGDK v0.1.9
132
- ### Change Documentation URL
133
- ### Support API LogEvent(eventName, parameters)
140
+ - Release AmaGDK v0.1.9
141
+ - Change Documentation URL
142
+ - Support API LogEvent(eventName, parameters)
134
143
 
135
144
  ## [0.1.8 - 2023-02-15]
136
- ### Release AmaGDK v0.1.8
137
- ### Add AdapterID
145
+ - Release AmaGDK v0.1.8
146
+ - Add AdapterID
138
147
 
139
148
  ## [0.1.5 - 2023-02-13]
140
- ### Release AmaSDK v0.1.5
141
- ### Validate EventParams
149
+ - Release AmaSDK v0.1.5
150
+ - Validate EventParams
142
151
 
143
152
  ## [0.1.4 - 2023-02-13]
144
- ### Release AmaSDK v0.1.4
153
+ - Release AmaSDK v0.1.4
145
154
 
146
155
  ## [0.1.3 - 2023-02-10]
147
- ### Release AmaSDK v0.1.3
156
+ - Release AmaSDK v0.1.3
148
157
 
149
158
  ## [0.1.2] - 2023-02-08
150
- ### Release AmaGDK 0.1.2
151
- ### FirebaseAnalytics adapter compatible with FirebaseAnalytics SDK v9
152
- ### AppsFlyer adapter compatible with AppsFlyer SDK v6
159
+ - Release AmaGDK 0.1.2
160
+ - FirebaseAnalytics adapter compatible with FirebaseAnalytics SDK v9
161
+ - AppsFlyer adapter compatible with AppsFlyer SDK v6
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 7549d4283e5844b68b594b1dcb4add02
2
+ guid: 8143c4447d1894317ac84680e221eec3
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
package/README.md CHANGED
@@ -1,12 +1,57 @@
1
1
  # Amanotes GDK
2
2
 
3
- ### Before you begin
3
+ ## AmaGDK Dev Project Setup
4
4
 
5
- AmaGDK is a free library from Amanotes provides classes, interfaces and adapter packages for Unity game development.
5
+ ### Clone Project From GitLab
6
6
 
7
- # Amanotes GDK for your game
7
+ 1. Clone project from GitLab url: https://gitlab.amanotes.net/sdk/AmaSDK_v5
8
+ 2. Open terminal windows and cd to your project
9
+ 3. Run file create-links.sh (Link GDK folder children to GDKDev)
8
10
 
9
- # Getting started with AmaGDK
11
+ ![image](https://drive.google.com/uc?id=1mlilsAOxjRRqWbQPI-tSUDJamZiY01rm)
12
+
13
+ ### How To Open Project
14
+
15
+ * Open project GDKDev
16
+
17
+ ![image](https://drive.google.com/uc?id=1N2kM3N-LU22pgY_3Uhyq-YZdCmDTPxJa)
18
+
19
+ ### Main folder
20
+
21
+ * AmaGDK: adapters logic, example, installer, configs
22
+
23
+ * AmaGDKCore: core logic, packages
24
+
25
+ * AmaGDKDev: tools for dev as build tool, release tool
26
+
27
+ * AmaGDKTest: scenes test, unit test
28
+
29
+ ![image](https://drive.google.com/uc?id=1iYskLfKqFG95Ezsf_hUotnlHnTaAMTfW)
30
+
31
+ ### Switch To Dev Mode
32
+
33
+ 1. Add GDK_HOME variable to .zshrc file in Mac OS
34
+
35
+ * Step 1: Open terminal, input sudo nano `~/.zshrc`
36
+
37
+ * Step 2: Enter and input password, add new line export `GDK_HOME=/AmaGDKCoreFolderPath`
38
+
39
+ * Step 3: Press Ctr+X buttons -> Press Y button -> Press `Enter` button to save
40
+
41
+ ![image](https://drive.google.com/uc?id=11hUbHwTpkLuEhe3hjQEkaiTuJ0fNCR7X)
42
+
43
+ 2. Select AmaGDK prefab in scene → select `Change Dev Mode` in context menu
44
+
45
+ ![image](https://drive.google.com/uc?id=1tmbtcK9FmZf21HHpQYyICf5dN9FKUeKN)
46
+
47
+ ### Code Convention
48
+ [Convention](https://amanotesjsc.atlassian.net/wiki/spaces/AP/pages/3409413152)
49
+
50
+ ### Links Reference
51
+ [Reference](https://amanotesjsc.atlassian.net/wiki/spaces/AP/pages/3334930473)
52
+
53
+
54
+ ## Getting started with AmaGDK
10
55
 
11
56
  ### Add AmaGDK prefab to your bootstrap scene (the first scene in your game build settings)
12
57
  There are two ways to do:
@@ -35,10 +80,10 @@ public class YourGameSceneController
35
80
  }
36
81
  ```
37
82
 
38
- # Versioning
83
+ ### Versioning
39
84
 
40
85
  We use [SemVer](http://semver.org/) for versioning.
41
86
 
42
- # License
87
+ ### License
43
88
 
44
89
  This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
@@ -136,30 +136,12 @@ namespace Amanotes.Core
136
136
 
137
137
  public static void SetUserId(string userId)
138
138
  {
139
- if (listAdapters.Count == 0)
140
- {
141
- LogWarningOnce("ListAnalyticsAdapter is empty! Maybe you need to wait for Analytics to init");
142
- return;
143
- }
144
-
145
- foreach (AdapterContext s in listAdapters)
146
- {
147
- s.GetAdapterApi<IAnalyticAdapter>().SetUserId(userId);
148
- }
139
+ actionQueue.Enqueue(() => InternalSetUserId(userId));
149
140
  }
150
141
 
151
142
  public static void SetUserProperty(string key, string value)
152
143
  {
153
- if (listAdapters.Count == 0)
154
- {
155
- LogWarningOnce("ListAnalyticsAdapter is empty! Maybe you need to wait for Analytics to init");
156
- return;
157
- }
158
-
159
- foreach (AdapterContext s in listAdapters)
160
- {
161
- s.GetAdapterApi<IAnalyticAdapter>().SetUserProperty(key, value);
162
- }
144
+ actionQueue.Enqueue(() => InternalSetUserProperty(key, value));
163
145
  }
164
146
 
165
147
  private static IntegrityFlag MergeData(List<string> funnelEvents, Dictionary<string, int> eventCountMap, bool sumEventCount)
@@ -285,6 +267,7 @@ namespace Amanotes.Core
285
267
  internal static readonly Dictionary<string, EventConfig> sendAtCount = new Dictionary<string, EventConfig>();
286
268
  internal static Predicate<EventParams> logEventHook = null;
287
269
  internal static readonly Queue<EventParams> eventQueue = new Queue<EventParams>();
270
+ internal static readonly Queue<Action> actionQueue = new Queue<Action>();
288
271
  internal static readonly List<AdapterContext> listAdapters = new List<AdapterContext>();
289
272
  internal static readonly AnalyticsData localData = new AnalyticsData().LoadJsonFromFile();
290
273
  internal static readonly SessionStat sessionStat = new SessionStat();
@@ -296,6 +279,9 @@ namespace Amanotes.Core
296
279
 
297
280
  onFrameUpdate -= ProcessEventQueue;
298
281
  onFrameUpdate += ProcessEventQueue;
282
+
283
+ onFrameUpdate -= ProcessActionQueue;
284
+ onFrameUpdate += ProcessActionQueue;
299
285
  }
300
286
 
301
287
  internal static void ProcessEventQueue()
@@ -389,7 +375,7 @@ namespace Amanotes.Core
389
375
  sb.AppendLine($" - Malformed eventName (should not contains <space> or <dash>: <{eventName}>");
390
376
  }
391
377
  }
392
-
378
+
393
379
  if (!char.IsLetter(eventName[0])) sb.AppendLine($" - EventName must start with a letter: <{eventName}> ");
394
380
  if (eventName.Length > 40) sb.AppendLine($" - EventName is too long ({eventName.Length} > 40): <{eventName}> ");
395
381
  if (sb.Length > 0 && dryRun) LogWarningOnce(sb.ToString(), $"NormalizeEventName<{eventName}>");
@@ -418,6 +404,33 @@ namespace Amanotes.Core
418
404
 
419
405
  return true;
420
406
  }
407
+
408
+
409
+ internal static void ProcessActionQueue()
410
+ {
411
+ if (actionQueue.Count <= 0) return;
412
+ while (actionQueue.Count > 0)
413
+ {
414
+ var action = actionQueue.Dequeue();
415
+ action.Invoke();
416
+ }
417
+ }
418
+
419
+ internal static void InternalSetUserId(string userId)
420
+ {
421
+ foreach (AdapterContext s in listAdapters)
422
+ {
423
+ s.GetAdapterApi<IAnalyticAdapter>().SetUserId(userId);
424
+ }
425
+ }
426
+
427
+ internal static void InternalSetUserProperty(string key, string value)
428
+ {
429
+ foreach (AdapterContext s in listAdapters)
430
+ {
431
+ s.GetAdapterApi<IAnalyticAdapter>().SetUserProperty(key, value);
432
+ }
433
+ }
421
434
  }
422
435
 
423
436
  //PERSISTENT DATA
@@ -83,10 +83,19 @@ namespace Amanotes.Core.Internal
83
83
  #endif
84
84
  }
85
85
 
86
+ [Flags]
87
+ public enum LogLevel
88
+ {
89
+ None = 0,
90
+ Error = 1,
91
+ Warning = 2,
92
+ Verbose = 4
93
+ }
94
+
86
95
  [Serializable]
87
96
  public partial class SDKConfig
88
97
  {
89
- public bool verboseLog;
98
+ public LogLevel logLevel = LogLevel.Warning | LogLevel.Error;
90
99
  }
91
100
 
92
101
  [Serializable]
@@ -438,7 +438,7 @@ namespace Amanotes.Core.Internal
438
438
  }
439
439
  onSuccess?.Invoke(dicProducts);
440
440
  return;
441
- #endif
441
+ #else
442
442
 
443
443
  getProdQueue.Clear();
444
444
  var subs = new List<string>();
@@ -468,6 +468,7 @@ namespace Amanotes.Core.Internal
468
468
  getProdQueue.Enqueue((cons, ProductType.Consumable));
469
469
  getProdQueue.Enqueue((nons, ProductType.NonConsumable));
470
470
  GetNextProductsInQueue();
471
+ #endif
471
472
  }
472
473
 
473
474
  void GetNextProductsInQueue()
@@ -68,6 +68,7 @@ namespace Amanotes.Core.Internal
68
68
 
69
69
  public static void LogWarningOnce(string message, string key = null)
70
70
  {
71
+ if ((Config.common.logLevel & LogLevel.Warning) == 0) return;
71
72
  if (string.IsNullOrEmpty(key)) key = message;
72
73
  if (logWarningDict.Contains(key)) return;
73
74
  logWarningDict.Add(key);
@@ -75,15 +76,15 @@ namespace Amanotes.Core.Internal
75
76
  }
76
77
  public static void LogWarning(string message)
77
78
  {
78
- Debug.LogWarning($"AmaGDK {message}");
79
+ if ((Config.common.logLevel & LogLevel.Warning) != 0) Debug.LogWarning($"AmaGDK {message}");
79
80
  }
80
81
  public static void LogError(string message)
81
82
  {
82
- Debug.LogError($"AmaGDK {message}");
83
+ if ((Config.common.logLevel & LogLevel.Error) != 0) Debug.LogError($"AmaGDK {message}");
83
84
  }
84
85
  public static void Log(string message)
85
86
  {
86
- if (AmaGDK.Config.common.verboseLog) Debug.Log($"AmaGDK {message}");
87
+ if ((Config.common.logLevel & LogLevel.Verbose) != 0) Debug.Log($"AmaGDK {message}");
87
88
  }
88
89
  }
89
90
 
@@ -91,10 +92,10 @@ namespace Amanotes.Core.Internal
91
92
  {
92
93
  public static void DestroyAndReset()
93
94
  {
94
- if (AmaGDK._instance != null)
95
+ if (_instance != null)
95
96
  {
96
- UnityObject.Destroy(AmaGDK._instance);
97
- AmaGDK._instance = null;
97
+ UnityObject.Destroy(_instance);
98
+ _instance = null;
98
99
  }
99
100
 
100
101
  AmaGDK[] result = Resources.FindObjectsOfTypeAll<AmaGDK>();
@@ -113,8 +114,8 @@ namespace Amanotes.Core.Internal
113
114
  UnityObject.Destroy(result[i].gameObject);
114
115
  }
115
116
 
116
- AmaGDK._status = Status.None;
117
- AmaGDK._allowInit = false;
117
+ _status = Status.None;
118
+ _allowInit = false;
118
119
 
119
120
  // TODO: Destroy adapters? - Don't do this. An adapter registers just 1 time. Clear adapters cause Analytics test fail.
120
121
  //Adapter.listAdapters.Clear();
@@ -1,11 +1,12 @@
1
1
  using System;
2
+ using System.Collections;
2
3
  using Amanotes.Core.Internal;
3
4
  using UnityEngine;
4
5
  namespace Amanotes.Core
5
6
  {
6
7
  public partial class AmaGDK //User profile
7
8
  {
8
- public static readonly UserProfile User = new UserProfile().Load();
9
+ public static readonly UserProfile User = new UserProfile();
9
10
 
10
11
  [Serializable]
11
12
  public partial class UserProfile : IJsonFile
@@ -18,14 +19,6 @@ namespace Amanotes.Core
18
19
  GDKFileUtils.Save(FILE_NAME, JsonUtility.ToJson(this));
19
20
  }
20
21
 
21
- internal UserProfile Load()
22
- {
23
- string json = GDKFileUtils.Load(FILE_NAME);
24
- if (string.IsNullOrEmpty(json)) return this;
25
- JsonUtility.FromJsonOverwrite(json, this);
26
- return this;
27
- }
28
-
29
22
  internal void SaveIfDirty()
30
23
  {
31
24
  if (!_dirty) return;
@@ -57,10 +50,26 @@ namespace Amanotes.Core
57
50
  private string appsFlyerId;
58
51
 
59
52
  private const string AMA_DEVICE_ID_KEY = "ama_device_id";
53
+ private const float TIME_OUT = 5f;
54
+ private const float WAIT_TIME = 0.5f;
55
+ private WaitForSeconds waitForDuration = new WaitForSeconds(WAIT_TIME);
60
56
 
61
- internal void InitUserProfile()
57
+ internal IEnumerator Init()
62
58
  {
63
- if (!IsAmaDeviceIdExist()) GetAdvertisingId();
59
+ User.LoadJsonFromFile();
60
+ if (IsAmaDeviceIdExist()) yield break;
61
+
62
+ GetAdvertisingId();
63
+
64
+ float time = 0;
65
+ while (!User.IsAmaDeviceIdExist())
66
+ {
67
+ yield return waitForDuration;
68
+ time += WAIT_TIME;
69
+ if (time <= TIME_OUT) continue;
70
+ Logging.LogWarning($"User init time out: {TIME_OUT}");
71
+ break;
72
+ }
64
73
  }
65
74
 
66
75
  private bool IsAmaDeviceIdExist()
@@ -118,7 +127,7 @@ namespace Amanotes.Core
118
127
  break;
119
128
 
120
129
  default:
121
- Logging.LogWarning($"Not support ama_device_id on: {Application.platform}");
130
+ amaDeviceId = SystemInfo.deviceUniqueIdentifier;
122
131
  break;
123
132
  }
124
133
  Logging.Log($"Generate AmaDeviceId completed: {amaDeviceId}");
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,23 @@ 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.20";
17
+ public const string VERSION = "0.2.22";
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
+
26
29
  internal static ConfigAsset Config
27
30
  {
28
31
  get
@@ -53,7 +56,7 @@ namespace Amanotes.Core
53
56
  _allowInit = _allowInit || autoInit;
54
57
  StartCoroutine(InitRoutine());
55
58
  }
56
-
59
+
57
60
  IEnumerator InitRoutine()
58
61
  {
59
62
  if (Config == null)
@@ -61,6 +64,8 @@ namespace Amanotes.Core
61
64
  throw new Exception("[AmaGDK] " + CONFIG_NOT_FOUND);
62
65
  }
63
66
 
67
+ yield return User.Init();
68
+
64
69
  float time = 0;
65
70
  float timeout = 10;
66
71
 
@@ -81,7 +86,7 @@ namespace Amanotes.Core
81
86
 
82
87
  _status = Status.Initialize;
83
88
  float startTime = Time.realtimeSinceStartup;
84
- StringBuilder adapterInfo = new StringBuilder();
89
+ StringBuilder adapterAnnounce = new StringBuilder();
85
90
 
86
91
  // sort on priority
87
92
  Adapter.listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
@@ -90,7 +95,7 @@ namespace Amanotes.Core
90
95
  Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder}");
91
96
  adapter.Init();
92
97
  RegisterUnityCallback(adapter);
93
-
98
+
94
99
  time = 0;
95
100
 
96
101
  while (!adapter.IsReady)
@@ -101,12 +106,16 @@ namespace Amanotes.Core
101
106
  LogWarning($"{adapter.adapterId} init time out: {timeout}");
102
107
  break;
103
108
  }
104
-
105
- adapterInfo.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL", adapter.adapterId, adapter.adapterVersion));
109
+
110
+ var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady);
111
+ _adapters.Add(adapter.adapterId, adapterInfo);
112
+ _onAdapterReadyCallback?.Invoke(adapterInfo);
113
+ adapterAnnounce.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL",
114
+ adapter.adapterId, adapter.adapterVersion));
106
115
  }
116
+ _onAdapterReadyCallback = null;
107
117
 
108
118
  // Init modules (Adapter managers)
109
- User.InitUserProfile();
110
119
  Analytics.Init();
111
120
  Ads.Init();
112
121
  IAP.Init();
@@ -114,20 +123,22 @@ namespace Amanotes.Core
114
123
  _status = Status.Ready;
115
124
  _onReadyCallback?.Invoke();
116
125
  _onReadyCallback = null;
117
- Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterInfo.ToString()}");
126
+ Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterAnnounce.ToString()}");
118
127
  }
119
128
 
120
129
  void RegisterUnityCallback(AdapterContext adapter)
121
130
  {
122
131
  switch (adapter)
123
132
  {
124
- case IOnFrameUpdate a: {
133
+ case IOnFrameUpdate a:
134
+ {
125
135
  onFrameUpdate -= a.OnFrameUpdate;
126
136
  onFrameUpdate += a.OnFrameUpdate;
127
137
  break;
128
138
  }
129
139
 
130
- case IOnApplicationPause a: {
140
+ case IOnApplicationPause a:
141
+ {
131
142
  onApplicationPause -= a.OnApplicationPause;
132
143
  onApplicationPause += a.OnApplicationPause;
133
144
  break;
@@ -139,16 +150,16 @@ namespace Amanotes.Core
139
150
  applicationFocus += a.OnApplicationFocus;
140
151
  break;
141
152
  }
142
-
153
+
143
154
  case IOnApplicationQuit a:
144
155
  {
145
156
  applicationQuit -= a.OnApplicationQuit;
146
157
  applicationQuit += a.OnApplicationQuit;
147
- break;
158
+ break;
148
159
  }
149
160
  }
150
161
  }
151
-
162
+
152
163
  }
153
164
 
154
165
  public partial class AmaGDK // PUBLIC APIS
@@ -187,12 +198,40 @@ namespace Amanotes.Core
187
198
  {
188
199
  if (onReady == null)
189
200
  {
190
- LogWarning("Can not add a null callback!");
201
+ LogWarning("Cannot add a null callback!");
191
202
  return;
192
203
  }
193
204
  _onReadyCallback -= onReady;
194
205
  _onReadyCallback += onReady;
195
206
  }
207
+
208
+ public static void SetAdapterReadyCallback(Action<AdapterInfo> onAdapterReady)
209
+ {
210
+ if (onAdapterReady == null)
211
+ {
212
+ LogWarning("Cannot add a null callback!");
213
+ return;
214
+ }
215
+ _onAdapterReadyCallback -= onAdapterReady;
216
+ _onAdapterReadyCallback += onAdapterReady;
217
+ }
218
+
219
+ public static AdapterInfo GetAdapterInfo(string id)
220
+ {
221
+ if (string.IsNullOrWhiteSpace(id))
222
+ {
223
+ LogWarning("Please provide Adapter ID to get the info.");
224
+ return default;
225
+ }
226
+
227
+ if (!_adapters.ContainsKey(id))
228
+ {
229
+ LogWarning($"Adapter {id} is not found.");
230
+ return default;
231
+ }
232
+
233
+ return _adapters[id];
234
+ }
196
235
  }
197
236
 
198
237
  public partial class AmaGDK
@@ -237,7 +276,7 @@ namespace Amanotes.Core
237
276
  }
238
277
  }
239
278
 
240
- public partial class AmaGDK // Switch dev mode
279
+ public partial class AmaGDK // Switch dev mode
241
280
  {
242
281
  [ContextMenu("Change Dev Mode")]
243
282
  public void ChangeDevMode()
@@ -280,4 +319,18 @@ namespace Amanotes.Core
280
319
  File.WriteAllText(manifestPath, manifestJson);
281
320
  }
282
321
  }
322
+
323
+ public struct AdapterInfo
324
+ {
325
+ public string id;
326
+ public string version;
327
+ public bool isReady;
328
+
329
+ public AdapterInfo(string id, string version, bool isReady)
330
+ {
331
+ this.id = id;
332
+ this.version = version;
333
+ this.isReady = isReady;
334
+ }
335
+ }
283
336
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",