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 +4 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdRevenuePlugin.unitypackage +0 -0
- package/Packages/AppsFlyerAdRevenuePlugin.unitypackage.meta +7 -0
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/IronSourceAdapter_v7.2.6.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
- package/Runtime/AmaGDK.AdEvents.cs +297 -0
- package/Runtime/AmaGDK.AdEvents.cs.meta +11 -0
- package/Runtime/AmaGDK.Adapters.cs +2 -0
- package/Runtime/AmaGDK.Ads.cs +8 -0
- package/Runtime/AmaGDK.Analytics.cs +2 -0
- package/Runtime/AmaGDK.IAP.cs +1 -0
- package/Runtime/AmaGDK.UserProfile.cs +163 -28
- package/Runtime/AmaGDK.cs +16 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -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
|
package/Runtime/AmaGDK.IAP.cs
CHANGED
|
@@ -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
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
98
|
+
private string _gaid;
|
|
41
99
|
[SerializeField]
|
|
42
|
-
private string
|
|
100
|
+
private string _idfa;
|
|
43
101
|
[SerializeField]
|
|
44
|
-
private string
|
|
102
|
+
private string _idfv;
|
|
45
103
|
[SerializeField]
|
|
46
|
-
private string
|
|
104
|
+
private string _androidId;
|
|
47
105
|
[SerializeField]
|
|
48
|
-
private string
|
|
106
|
+
private string _pseudoId;
|
|
107
|
+
[SerializeField]
|
|
108
|
+
private string _amaDeviceId;
|
|
109
|
+
[SerializeField]
|
|
110
|
+
private string _appsFlyerId;
|
|
49
111
|
[SerializeField]
|
|
50
|
-
private string
|
|
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(
|
|
202
|
+
if (!string.IsNullOrEmpty(_amaDeviceId))
|
|
76
203
|
{
|
|
77
|
-
Logging.Log($"AmaDeviceId is already existed: {
|
|
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
|
-
|
|
89
|
-
|
|
215
|
+
IDFA = id;
|
|
216
|
+
IDFV = SystemInfo.deviceUniqueIdentifier;
|
|
90
217
|
break;
|
|
91
218
|
case RuntimePlatform.Android:
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
242
|
+
AmaDeviceId = v;
|
|
115
243
|
break;
|
|
116
244
|
|
|
117
245
|
case RuntimePlatform.Android:
|
|
118
|
-
string
|
|
119
|
-
if (string.IsNullOrEmpty(
|
|
246
|
+
string cachedAmaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
|
|
247
|
+
if (string.IsNullOrEmpty(cachedAmaDeviceId))
|
|
120
248
|
{
|
|
121
|
-
|
|
122
|
-
PlayerPrefs.SetString(AMA_DEVICE_ID_KEY,
|
|
249
|
+
cachedAmaDeviceId = SystemInfo.deviceUniqueIdentifier;
|
|
250
|
+
PlayerPrefs.SetString(AMA_DEVICE_ID_KEY, cachedAmaDeviceId);
|
|
123
251
|
}
|
|
124
|
-
|
|
252
|
+
AmaDeviceId = cachedAmaDeviceId;
|
|
125
253
|
break;
|
|
126
254
|
|
|
127
255
|
default:
|
|
128
|
-
|
|
256
|
+
AmaDeviceId = SystemInfo.deviceUniqueIdentifier;
|
|
129
257
|
break;
|
|
130
258
|
}
|
|
131
|
-
Logging.Log($"Generate AmaDeviceId completed: {
|
|
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.
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
}
|