com.amanotes.gdk 0.2.31 → 0.2.32

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.32 - 2023-11-08]
4
+ - User mapping
5
+ - Auto log Ad events
6
+
3
7
  ## [0.2.31 - 2023-11-06]
4
8
  - [Fix] False alarm when video reward ready
5
9
  - [Fix] Callbacks should trigger earlier (being delayed like 1s)
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 86143bf1eeccc4df3832a37f7548e2ff
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,297 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using Amanotes.Core.Internal;
5
+ using UnityEngine;
6
+
7
+ namespace Amanotes.Core
8
+ {
9
+ public partial class AmaGDK // Ad events
10
+ {
11
+ public static class AdEventContext
12
+ {
13
+ public delegate void UpdateAdEventContext (string eventName);
14
+ /// <summary>
15
+ /// Update AdEventContext's variables for ad event tracking
16
+ /// </summary>
17
+ public static event UpdateAdEventContext Update;
18
+
19
+ public static string connection;
20
+ public static string location;
21
+ public static string songACMid;
22
+ public static string songName;
23
+ public static string songUnlockType;
24
+ public static string reward;
25
+ public static string mediation;
26
+ public static Dictionary<string, object> customData = new Dictionary<string, object>();
27
+
28
+ internal static void UpdateFor(string eventName)
29
+ {
30
+ connection = null;
31
+ location = null;
32
+ songACMid = null;
33
+ songName = null;
34
+ songUnlockType = null;
35
+ reward = null;
36
+ mediation = null;
37
+ customData.Clear();
38
+ Update?.Invoke(eventName);
39
+ }
40
+ }
41
+
42
+ public partial class AdEvents //Event name
43
+ {
44
+ const string FULLADS_REQUEST = "fullads_request";
45
+ const string FULLADS_REQUEST_FAILED = "fullads_request_failed";
46
+ const string FULLADS_REQUEST_SUCCESS = "fullads_request_success";
47
+ const string FULLADS_SHOW_READY = "fullads_show_ready";
48
+ const string FULLADS_SHOW_NOTREADY = "fullads_show_notready";
49
+ const string FULLADS_SHOW = "fullads_show";
50
+ const string FULLADS_SHOW_FAILED = "fullads_show_failed";
51
+ const string FULLADS_FINISH = "fullads_finish";
52
+ const string FULLADS_CLICK = "fullads_click";
53
+
54
+ const string VIDEOADS_SHOW_READY = "videoads_show_ready";
55
+ const string VIDEOADS_SHOW_NOTREADY = "videoads_show_notready";
56
+ const string VIDEOADS_SHOW = "videoads_show";
57
+ const string VIDEOADS_SHOW_FAILED = "videoads_show_failed";
58
+ const string VIDEOADS_FINISH = "videoads_finish";
59
+ const string VIDEOADS_CLICK = "videoads_click";
60
+
61
+ const string BANNER_CLICK = "bannerads_click";
62
+
63
+ //Parameter name
64
+ const string PARAM_CONNECTION = "connection";
65
+ const string PARAM_LOCATION = "location";
66
+ const string PARAM_SONG_ACM_ID = "song_acm_id";
67
+ const string PARAM_SONG_NAME = "song_name";
68
+ const string PARAM_SONG_UNLOCK_TYPE = "song_unlock_type";
69
+ const string PARAM_REWARD = "reward";
70
+ const string PARAM_MEDIATION = "mediation";
71
+ }
72
+
73
+ public partial class AdEvents //Impression
74
+ {
75
+ public static Action<Dictionary<string, object>> onAdImpression;
76
+
77
+ public static void LogAdImpression(Dictionary<string, object> impressionData)
78
+ {
79
+ Analytics.LogEvent("ad_impression", impressionData)
80
+ .OnlyTo(AmaGDK.AdapterID.FIREBASE_ANALYTICS);
81
+ Analytics.LogEvent("ad_impression_ama", impressionData)
82
+ .OnlyTo(AmaGDK.AdapterID.FIREBASE_ANALYTICS);
83
+ }
84
+ }
85
+
86
+ public partial class AdEvents //Full ads
87
+ {
88
+ public static void LogFullAdsRequest()
89
+ {
90
+ AdEventContext.UpdateFor(FULLADS_REQUEST);
91
+ var dic = AdEventContext.customData;
92
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
93
+ dic[PARAM_LOCATION] = AdEventContext.location;
94
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
95
+ Analytics.LogEvent(FULLADS_REQUEST, dic).SetAsAccumulated();
96
+ }
97
+
98
+ public static void LogFullAdsRequestFailed()
99
+ {
100
+ AdEventContext.UpdateFor(FULLADS_REQUEST_FAILED);
101
+ var dic = AdEventContext.customData;
102
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
103
+ dic[PARAM_LOCATION] = AdEventContext.location;
104
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
105
+ Analytics.LogEvent(FULLADS_REQUEST_FAILED, dic).SetAsAccumulated();
106
+ }
107
+
108
+ public static void LogFullAdsRequestSuccess()
109
+ {
110
+ AdEventContext.UpdateFor(FULLADS_REQUEST_SUCCESS);
111
+ var dic = AdEventContext.customData;
112
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
113
+ dic[PARAM_LOCATION] = AdEventContext.location;
114
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
115
+ Analytics.LogEvent(FULLADS_REQUEST_SUCCESS, dic).SetAsAccumulated();
116
+ }
117
+
118
+ public static void LogFullAdsShowReady()
119
+ {
120
+ AdEventContext.UpdateFor(FULLADS_SHOW_READY);
121
+ var dic = AdEventContext.customData;
122
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
123
+ dic[PARAM_LOCATION] = AdEventContext.location;
124
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
125
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
126
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
127
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
128
+ Analytics.LogEvent(FULLADS_SHOW_READY, dic).SetAsAccumulated();
129
+ }
130
+
131
+ public static void LogFullAdsShowNotReady()
132
+ {
133
+ AdEventContext.UpdateFor(FULLADS_SHOW_NOTREADY);
134
+ var dic = AdEventContext.customData;
135
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
136
+ dic[PARAM_LOCATION] = AdEventContext.location;
137
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
138
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
139
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
140
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
141
+ Analytics.LogEvent(FULLADS_SHOW_NOTREADY, dic).SetAsAccumulated();
142
+ }
143
+
144
+ public static void LogFullAdsShow()
145
+ {
146
+ AdEventContext.UpdateFor(FULLADS_SHOW);
147
+ var dic = AdEventContext.customData;
148
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
149
+ dic[PARAM_LOCATION] = AdEventContext.location;
150
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
151
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
152
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
153
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
154
+ Analytics.LogEvent(FULLADS_SHOW, dic).SetAsAccumulated();
155
+ }
156
+
157
+ public static void LogFullAdsShowFailed()
158
+ {
159
+ AdEventContext.UpdateFor(FULLADS_SHOW_FAILED);
160
+ var dic = AdEventContext.customData;
161
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
162
+ dic[PARAM_LOCATION] = AdEventContext.location;
163
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
164
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
165
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
166
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
167
+ Analytics.LogEvent(FULLADS_SHOW_FAILED, dic).SetAsAccumulated();
168
+ }
169
+
170
+ public static void LogFullAdsFinish()
171
+ {
172
+ AdEventContext.UpdateFor(FULLADS_FINISH);
173
+ var dic = AdEventContext.customData;
174
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
175
+ dic[PARAM_LOCATION] = AdEventContext.location;
176
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
177
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
178
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
179
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
180
+ Analytics.LogEvent(FULLADS_FINISH, dic).SetAsAccumulated();
181
+ }
182
+
183
+ public static void LogFullAdsClick()
184
+ {
185
+ AdEventContext.UpdateFor(FULLADS_CLICK);
186
+ var dic = AdEventContext.customData;
187
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
188
+ dic[PARAM_LOCATION] = AdEventContext.location;
189
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
190
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
191
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
192
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
193
+ Analytics.LogEvent(FULLADS_CLICK, dic).SetAsAccumulated();
194
+ }
195
+ }
196
+
197
+ public partial class AdEvents //Rewarded
198
+ {
199
+ public static void LogVideoAdsShowReady()
200
+ {
201
+ AdEventContext.UpdateFor(VIDEOADS_SHOW_READY);
202
+ var dic = AdEventContext.customData;
203
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
204
+ dic[PARAM_LOCATION] = AdEventContext.location;
205
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
206
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
207
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
208
+ dic[PARAM_REWARD] = AdEventContext.reward;
209
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
210
+ Analytics.LogEvent(VIDEOADS_SHOW_READY, dic).SetAsAccumulated();
211
+ }
212
+
213
+ public static void LogVideoAdsShowNotReady()
214
+ {
215
+ AdEventContext.UpdateFor(VIDEOADS_SHOW_NOTREADY);
216
+ var dic = AdEventContext.customData;
217
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
218
+ dic[PARAM_LOCATION] = AdEventContext.location;
219
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
220
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
221
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
222
+ dic[PARAM_REWARD] = AdEventContext.reward;
223
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
224
+ Analytics.LogEvent(VIDEOADS_SHOW_NOTREADY, dic).SetAsAccumulated();
225
+ }
226
+
227
+ public static void LogVideoAdsShow()
228
+ {
229
+ AdEventContext.UpdateFor(VIDEOADS_SHOW);
230
+ var dic = AdEventContext.customData;
231
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
232
+ dic[PARAM_LOCATION] = AdEventContext.location;
233
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
234
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
235
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
236
+ dic[PARAM_REWARD] = AdEventContext.reward;
237
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
238
+ Analytics.LogEvent(VIDEOADS_SHOW, dic).SetAsAccumulated();
239
+ }
240
+
241
+ public static void LogVideoAdsShowFailed()
242
+ {
243
+ AdEventContext.UpdateFor(VIDEOADS_SHOW_FAILED);
244
+ var dic = AdEventContext.customData;
245
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
246
+ dic[PARAM_LOCATION] = AdEventContext.location;
247
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
248
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
249
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
250
+ dic[PARAM_REWARD] = AdEventContext.reward;
251
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
252
+ Analytics.LogEvent(VIDEOADS_SHOW_FAILED, dic).SetAsAccumulated();
253
+ }
254
+
255
+ public static void LogVideoAdsFinish()
256
+ {
257
+ AdEventContext.UpdateFor(VIDEOADS_FINISH);
258
+ var dic = AdEventContext.customData;
259
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
260
+ dic[PARAM_LOCATION] = AdEventContext.location;
261
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
262
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
263
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
264
+ dic[PARAM_REWARD] = AdEventContext.reward;
265
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
266
+ Analytics.LogEvent(VIDEOADS_FINISH, dic).SetAsAccumulated();
267
+ }
268
+
269
+ public static void LogVideoAdsClick()
270
+ {
271
+ AdEventContext.UpdateFor(VIDEOADS_CLICK);
272
+ var dic = AdEventContext.customData;
273
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
274
+ dic[PARAM_LOCATION] = AdEventContext.location;
275
+ dic[PARAM_SONG_ACM_ID] = AdEventContext.songACMid;
276
+ dic[PARAM_SONG_NAME] = AdEventContext.songName;
277
+ dic[PARAM_SONG_UNLOCK_TYPE] = AdEventContext.songUnlockType;
278
+ dic[PARAM_REWARD] = AdEventContext.reward;
279
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
280
+ Analytics.LogEvent(VIDEOADS_CLICK, dic).SetAsAccumulated();
281
+ }
282
+ }
283
+
284
+ public partial class AdEvents //Banner
285
+ {
286
+ public static void LogBannerClick()
287
+ {
288
+ AdEventContext.UpdateFor(BANNER_CLICK);
289
+ var dic = AdEventContext.customData;
290
+ dic[PARAM_CONNECTION] = AdEventContext.connection;
291
+ dic[PARAM_LOCATION] = AdEventContext.location;
292
+ dic[PARAM_MEDIATION] = AdEventContext.mediation;
293
+ Analytics.LogEvent(BANNER_CLICK, dic).SetAsAccumulated();
294
+ }
295
+ }
296
+ }
297
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d65e821f5d1ce4c05aead50ca80d5b12
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,6 +1,7 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
3
  using System.Linq;
4
+ using UnityEngine;
4
5
  using static Amanotes.Core.Internal.Logging;
5
6
 
6
7
  namespace Amanotes.Core.Internal
@@ -10,6 +11,7 @@ namespace Amanotes.Core.Internal
10
11
  public string adapterId;
11
12
  public string adapterVersion;
12
13
  public int initOrder;
14
+ public GameObject refObj;
13
15
 
14
16
  // Status support
15
17
  public Status status = Status.None;
@@ -110,6 +110,7 @@ namespace Amanotes.Core
110
110
  [Serializable]
111
111
  public class AdAdapterConfig
112
112
  {
113
+ public bool autoInit;
113
114
  public int adLoadTimeoutInSecs = 60;
114
115
  public int adShowTimeoutInSecs = 5;
115
116
  public BannerPosition bannerPosition = BannerPosition.BOTTOM;
@@ -256,6 +257,11 @@ namespace Amanotes.Core
256
257
  public static int TimeSinceLastVideoReward => localData.TimeSinceLastShow(AdType.VideoReward);
257
258
 
258
259
  public static int TimeSinceLastAd => Math.Min(TimeSinceLastInterstitial, TimeSinceLastVideoReward) ;
260
+
261
+ public static void SetUserId(string userId)
262
+ {
263
+ _adapter.SetUserId(userId);
264
+ }
259
265
  }
260
266
  }
261
267
  }
@@ -274,6 +280,8 @@ namespace Amanotes.Core.Internal
274
280
 
275
281
  void ShowBanner(BannerPosition position);
276
282
  void HideBanner();
283
+
284
+ void SetUserId(string userId);
277
285
  }
278
286
 
279
287
  public enum LoadAdsState
@@ -771,5 +771,7 @@ namespace Amanotes.Core.Internal
771
771
  void SetUserId(string userId);
772
772
 
773
773
  void SetUserProperty(string key, string value);
774
+
775
+ void GetAppInstanceID(Action<string> appId);
774
776
  }
775
777
  }
@@ -407,6 +407,7 @@ namespace Amanotes.Core.Internal
407
407
  [Serializable]
408
408
  public class IAPAdapterConfig
409
409
  {
410
+ public bool autoInit;
410
411
  [SerializeField] internal bool allPurchaseSuccessInEditor;
411
412
  [SerializeField] internal List<ProductInfo> products;
412
413
  [SerializeField] internal bool autoGetProducts;
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Text.RegularExpressions;
3
4
  using Amanotes.Core.Internal;
4
5
  using UnityEngine;
5
6
  namespace Amanotes.Core
@@ -7,6 +8,7 @@ namespace Amanotes.Core
7
8
  public partial class AmaGDK //User profile
8
9
  {
9
10
  public static readonly UserProfile User = new UserProfile();
11
+ public static event Action<string> OnUserIdChanged;
10
12
 
11
13
  [Serializable]
12
14
  public partial class UserProfile : IJsonFile
@@ -26,28 +28,92 @@ namespace Amanotes.Core
26
28
  this.SaveJsonToFile();
27
29
  }
28
30
  }
29
-
30
- public partial class UserProfile
31
+
32
+ public partial class UserProfile //PUBLIC
31
33
  {
32
- public string GAId => gaid;
33
- public string IDFA => idfa;
34
- public string IDFV => idfv;
35
- public string AndroidId => androidId;
36
- public string AmaDeviceId => amaDeviceId;
37
- public string AppsFlyerId => appsFlyerId;
34
+ public string UserId
35
+ {
36
+ get => _userId;
37
+ private set
38
+ {
39
+ _userId = value;
40
+ OnUserIdChanged?.Invoke(_userId);
41
+ }
42
+ }
43
+
44
+ public string GAId
45
+ {
46
+ get => _gaid;
47
+ set => _gaid = ValidateId(value, ALPHANUMERIC_HYPHEN_PATTERN);
48
+ }
49
+
50
+ public string IDFA
51
+ {
52
+ get => _idfa;
53
+ set => _idfa = ValidateId(value, ALPHANUMERIC_HYPHEN_PATTERN);
54
+ }
55
+
56
+ public string IDFV
57
+ {
58
+ get => _idfv;
59
+ set => _idfv = ValidateId(value, ALPHANUMERIC_HYPHEN_PATTERN);
60
+ }
61
+
62
+ public string AndroidId
63
+ {
64
+ get => _androidId;
65
+ set => _androidId = ValidateId(value, ALPHANUMERIC_PATTERN);
66
+ }
38
67
 
68
+ public string PseudoId
69
+ {
70
+ get => _pseudoId;
71
+ set => _pseudoId = ValidateId(value, ALPHANUMERIC_PATTERN);
72
+ }
73
+
74
+ public string AmaDeviceId
75
+ {
76
+ get => _amaDeviceId;
77
+ set => _amaDeviceId = ValidateId(value, ALPHANUMERIC_HYPHEN_PATTERN);
78
+ }
79
+
80
+ public string AppsFlyerId
81
+ {
82
+ get => _appsFlyerId;
83
+ set => _appsFlyerId = ValidateId(value, NUMERIC_HYPHEN_PATTERN);
84
+ }
85
+
86
+ public string InstallationId
87
+ {
88
+ get => _installationId;
89
+ set => _installationId = ValidateId(value, ALPHANUMERIC_PATTERN);
90
+ }
91
+ }
92
+
93
+ public partial class UserProfile //INTERNAL
94
+ {
95
+ [SerializeField]
96
+ private string _userId;
39
97
  [SerializeField]
40
- private string gaid;
98
+ private string _gaid;
41
99
  [SerializeField]
42
- private string idfa;
100
+ private string _idfa;
43
101
  [SerializeField]
44
- private string idfv;
102
+ private string _idfv;
45
103
  [SerializeField]
46
- private string androidId;
104
+ private string _androidId;
47
105
  [SerializeField]
48
- private string amaDeviceId;
106
+ private string _pseudoId;
107
+ [SerializeField]
108
+ private string _amaDeviceId;
109
+ [SerializeField]
110
+ private string _appsFlyerId;
49
111
  [SerializeField]
50
- private string appsFlyerId;
112
+ private string _installationId;
113
+
114
+ private const string ALPHANUMERIC_HYPHEN_PATTERN = @"^(?=.*\d)(?=.*[a-zA-Z])(?=.*-).+$";
115
+ private const string ALPHANUMERIC_PATTERN = @"^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z\d]+$";
116
+ private const string NUMERIC_HYPHEN_PATTERN = @"^(?=.*\d)(?=.*-)[\d-]+$";
51
117
 
52
118
  private const string AMA_DEVICE_ID_KEY = "ama_device_id";
53
119
  private const float TIME_OUT = 5f;
@@ -69,12 +135,73 @@ namespace Amanotes.Core
69
135
  break;
70
136
  }
71
137
  }
138
+
139
+ internal void UpdateUserId()
140
+ {
141
+ if (!string.IsNullOrWhiteSpace(_userId))
142
+ {
143
+ OnUserIdChanged?.Invoke(_userId);
144
+ return;
145
+ }
146
+
147
+ #if UNITY_ANDROID
148
+ if (!string.IsNullOrWhiteSpace(_gaid))
149
+ {
150
+ UserId = $"GAID-{_gaid}";
151
+ return;
152
+ }
153
+
154
+ if (!string.IsNullOrWhiteSpace(_androidId))
155
+ {
156
+ UserId = $"ADR-{_androidId}";
157
+ return;
158
+ }
159
+ #endif
160
+
161
+ #if UNITY_IOS
162
+ if (!string.IsNullOrWhiteSpace(_idfa))
163
+ {
164
+ UserId = $"IDFA-{_idfa}";
165
+ return;
166
+ }
167
+
168
+ if (!string.IsNullOrWhiteSpace(_idfv))
169
+ {
170
+ UserId = $"IDFV-{_idfv}";
171
+ return;
172
+ }
173
+ #endif
174
+
175
+ if (!string.IsNullOrWhiteSpace(_pseudoId))
176
+ {
177
+ UserId = $"FRB-{_pseudoId}";
178
+ return;
179
+ }
180
+
181
+ if (!string.IsNullOrWhiteSpace(_amaDeviceId))
182
+ {
183
+ UserId = $"AMA-{_amaDeviceId}";
184
+ return;
185
+ }
186
+
187
+ if (!string.IsNullOrWhiteSpace(_appsFlyerId))
188
+ {
189
+ UserId = $"AF-{_appsFlyerId}";
190
+ return;
191
+ }
192
+
193
+ if (!string.IsNullOrWhiteSpace(_installationId))
194
+ {
195
+ UserId = $"INS-{_installationId}";
196
+ return;
197
+ }
198
+ }
72
199
 
73
200
  private bool IsAmaDeviceIdExist()
74
201
  {
75
- if (!string.IsNullOrEmpty(amaDeviceId))
202
+ if (!string.IsNullOrEmpty(_amaDeviceId))
76
203
  {
77
- Logging.Log($"AmaDeviceId is already existed: {amaDeviceId}");
204
+ Logging.Log($"AmaDeviceId is already existed: {_amaDeviceId}");
78
205
  return true;
79
206
  }
80
207
  return false;
@@ -85,18 +212,19 @@ namespace Amanotes.Core
85
212
  switch (Application.platform)
86
213
  {
87
214
  case RuntimePlatform.IPhonePlayer:
88
- idfa = id;
89
- idfv = SystemInfo.deviceUniqueIdentifier;
215
+ IDFA = id;
216
+ IDFV = SystemInfo.deviceUniqueIdentifier;
90
217
  break;
91
218
  case RuntimePlatform.Android:
92
- gaid = id;
93
- androidId = SystemInfo.deviceUniqueIdentifier;
219
+ GAId = id;
220
+ AndroidId = SystemInfo.deviceUniqueIdentifier;
94
221
  break;
95
222
  default:
96
223
  Logging.LogWarning($"Unsupported platform: {Application.platform}");
97
224
  break;
98
225
  }
99
226
  }
227
+
100
228
  private void GetAdvertisingId()
101
229
  {
102
230
  AdvertisingIdFetcher.RequestAdvertisingId(advertisingId =>
@@ -111,27 +239,34 @@ namespace Amanotes.Core
111
239
  v = Guid.NewGuid().ToString();
112
240
  KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, v);
113
241
  }
114
- amaDeviceId = v;
242
+ AmaDeviceId = v;
115
243
  break;
116
244
 
117
245
  case RuntimePlatform.Android:
118
- string _amaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
119
- if (string.IsNullOrEmpty(amaDeviceId))
246
+ string cachedAmaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
247
+ if (string.IsNullOrEmpty(cachedAmaDeviceId))
120
248
  {
121
- _amaDeviceId = SystemInfo.deviceUniqueIdentifier;
122
- PlayerPrefs.SetString(AMA_DEVICE_ID_KEY, amaDeviceId);
249
+ cachedAmaDeviceId = SystemInfo.deviceUniqueIdentifier;
250
+ PlayerPrefs.SetString(AMA_DEVICE_ID_KEY, cachedAmaDeviceId);
123
251
  }
124
- amaDeviceId = _amaDeviceId;
252
+ AmaDeviceId = cachedAmaDeviceId;
125
253
  break;
126
254
 
127
255
  default:
128
- amaDeviceId = SystemInfo.deviceUniqueIdentifier;
256
+ AmaDeviceId = SystemInfo.deviceUniqueIdentifier;
129
257
  break;
130
258
  }
131
- Logging.Log($"Generate AmaDeviceId completed: {amaDeviceId}");
259
+ Logging.Log($"Generate AmaDeviceId completed: {_amaDeviceId}");
132
260
  User.Save();
133
261
  });
134
262
  }
263
+
264
+ private string ValidateId (string id, string pattern)
265
+ {
266
+ if (string.IsNullOrWhiteSpace(id)) return null;
267
+ if (!Regex.IsMatch(id, pattern)) return null;
268
+ return id;
269
+ }
135
270
  }
136
271
  }
137
272
  }
package/Runtime/AmaGDK.cs CHANGED
@@ -14,7 +14,7 @@ namespace Amanotes.Core
14
14
  {
15
15
  public partial class AmaGDK : MonoBehaviour
16
16
  {
17
- public const string VERSION = "0.2.31";
17
+ public const string VERSION = "0.2.32";
18
18
 
19
19
  internal static AmaGDK _instance;
20
20
  internal static Status _status = Status.None;
@@ -27,7 +27,7 @@ namespace Amanotes.Core
27
27
  private static readonly Dictionary<string, AdapterInfo> _adapters = new Dictionary<string, AdapterInfo>();
28
28
  private static readonly List<string> _firebaseServices = new List<string>() { AdapterID.FIREBASE_REMOTE_CONFIG, AdapterID.FIREBASE_ANALYTICS };
29
29
 
30
- internal static ConfigAsset Config
30
+ public static ConfigAsset Config
31
31
  {
32
32
  get
33
33
  {
@@ -99,7 +99,7 @@ namespace Amanotes.Core
99
99
 
100
100
  time = 0;
101
101
 
102
- while (!adapter.IsReady)
102
+ while (adapter.status == Status.None || adapter.status == Status.Initialize)
103
103
  {
104
104
  time += Time.deltaTime;
105
105
  yield return null;
@@ -113,11 +113,16 @@ namespace Amanotes.Core
113
113
  firebaseResolved = true;
114
114
  }
115
115
 
116
- var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady);
116
+ var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady, adapter.refObj);
117
117
  _adapters[adapter.adapterId] = adapterInfo;
118
118
  _onAdapterReadyCallback?.Invoke(adapterInfo);
119
119
  adapterAnnounce.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL",
120
120
  adapter.adapterId, adapter.adapterVersion));
121
+
122
+ if (adapter.adapterId == AdapterID.FIREBASE_ANALYTICS) User.UpdateUserId();
123
+
124
+ // Wait for postprocessing of each adapter
125
+ yield return null;
121
126
  }
122
127
  _onAdapterReadyCallback = null;
123
128
 
@@ -326,17 +331,19 @@ namespace Amanotes.Core
326
331
  }
327
332
  }
328
333
 
329
- public struct AdapterInfo
334
+ public class AdapterInfo
330
335
  {
331
- public string id;
332
- public string version;
333
- public bool isReady;
336
+ public readonly string id;
337
+ public readonly string version;
338
+ public readonly bool isReady;
339
+ public readonly GameObject refObj;
334
340
 
335
- public AdapterInfo(string id, string version, bool isReady)
341
+ public AdapterInfo(string id, string version, bool isReady, GameObject refObj)
336
342
  {
337
343
  this.id = id;
338
344
  this.version = version;
339
345
  this.isReady = isReady;
346
+ this.refObj = refObj;
340
347
  }
341
348
  }
342
349
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",