com.taptap.sdk.core 4.5.1 → 4.5.2

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.
@@ -4,12 +4,12 @@
4
4
  <repositories>
5
5
  <repository>https://repo.maven.apache.org/maven2</repository>
6
6
  </repositories>
7
- <androidPackage spec="com.taptap.sdk:tap-core-unity:4.5.1"/>
7
+ <androidPackage spec="com.taptap.sdk:tap-core-unity:4.5.2"/>
8
8
  </androidPackages>
9
9
  <iosPods>
10
10
  <sources>
11
11
  <source>https://github.com/CocoaPods/Specs.git</source>
12
12
  </sources>
13
- <iosPod name="TapTapCoreSDK" version="~> 4.5.1" bitcodeEnabled="false" addToAllTargets="false"/>
13
+ <iosPod name="TapTapCoreSDK" version="~> 4.5.2" bitcodeEnabled="false" addToAllTargets="false"/>
14
14
  </iosPods>
15
15
  </dependencies>
@@ -63,10 +63,7 @@ namespace TapSDK.Core.Internal.Log
63
63
  // 输出带有自定义颜色和标签的错误
64
64
  public static void Error(string message, string detail = null, string tag = TAG, string module = null)
65
65
  {
66
- if (Enabled)
67
- {
68
- Debug.LogError(GetFormattedMessage(message: message, detail: detail, colorHex: ErrorColor, tag: tag, module: module));
69
- }
66
+ Debug.LogError(GetFormattedMessage(message: message, detail: detail, colorHex: ErrorColor, tag: tag, module: module));
70
67
  }
71
68
 
72
69
  // 格式化带有颜色和标签的消息
@@ -8,6 +8,8 @@ namespace TapSDK.Core.Internal.Utils
8
8
  {
9
9
  public const string OnApplicationPause = "OnApplicationPause";
10
10
  public const string OnApplicationQuit = "OnApplicationQuit";
11
+
12
+ public const string OnComplianceUserChanged = "OnComplianceUserChanged";
11
13
  private Dictionary<string, Action<object>> eventRegistries = new Dictionary<string, Action<object>>();
12
14
 
13
15
  public static void AddListener(string eventName, Action<object> listener) {
@@ -0,0 +1,21 @@
1
+ using TapSDK.Core.Internal.Log;
2
+
3
+
4
+ namespace TapSDK.Core.Internal.Utils
5
+ {
6
+ public class TapVerifyInitStateUtils
7
+ {
8
+
9
+ public static void ShowVerifyErrorMsg(string error, string errorMsg)
10
+ {
11
+ if (error != null || error.Length > 0)
12
+ {
13
+ TapMessage.ShowMessage(error, TapMessage.Position.bottom, TapMessage.Time.twoSecond);
14
+ }
15
+ if (errorMsg != null && errorMsg.Length > 0)
16
+ {
17
+ TapLog.Error(errorMsg);
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2f1bb7b9efe304ef2a058482236a3e9e
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -12,7 +12,7 @@ using System.ComponentModel;
12
12
 
13
13
  namespace TapSDK.Core {
14
14
  public class TapTapSDK {
15
- public static readonly string Version = "4.5.1";
15
+ public static readonly string Version = "4.5.2";
16
16
 
17
17
  public static string SDKPlatform = "TapSDK-Unity";
18
18
 
@@ -67,6 +67,10 @@ namespace TapSDK.Core.Standalone.Internal.Http
67
67
  { "X-Tap-Lang", TapHttpUtils.GenerateLanguage()},
68
68
  { "User-Agent", TapHttpUtils.GenerateUserAgent()},
69
69
  };
70
+ string currentUserId = TapCoreStandalone.User?.Id;
71
+ if(currentUserId != null && currentUserId.Length > 0) {
72
+ headers.Add("X-Tap-SDK-Game-User-Id", currentUserId);
73
+ }
70
74
  if (enableAuthorization)
71
75
  {
72
76
  string authorization = TapHttpUtils.GenerateAuthorization(url, method.ToString());
@@ -75,6 +75,10 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
75
75
  {
76
76
  TdkOnAppStopped();
77
77
  });
78
+ EventManager.AddListener(EventManager.OnComplianceUserChanged, (userInfo) =>
79
+ {
80
+ TdkSetExtraAppDurationParams(userInfo.ToString());
81
+ });
78
82
  #endif
79
83
  }
80
84
 
@@ -22,6 +22,9 @@ namespace TapSDK.Core.Standalone
22
22
  internal static Tracker Tracker;
23
23
  internal static User User;
24
24
  internal static TapTapSdkOptions coreOptions;
25
+
26
+ // client 信息是否匹配
27
+ internal static bool isClientInfoMatched = true;
25
28
  internal static bool enableAutoEvent = true;
26
29
 
27
30
  internal static TapGatekeeper gatekeeperData = new TapGatekeeper();
@@ -56,6 +59,14 @@ namespace TapSDK.Core.Standalone
56
59
  /// <param name="otherOptions">Additional TapCore SDK options.</param>
57
60
  public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
58
61
  {
62
+ if (coreOption.clientId == null || coreOption.clientId.Length == 0){
63
+ TapVerifyInitStateUtils.ShowVerifyErrorMsg("clientId 不能为空","clientId 不能为空");
64
+ return;
65
+ }
66
+ if(coreOption.clientToken == null || coreOption.clientToken.Length == 0) {
67
+ TapVerifyInitStateUtils.ShowVerifyErrorMsg("clientToken 不能为空","clientToken 不能为空");
68
+ return;
69
+ }
59
70
  TapLog.Log("SDK Init Options : ", "coreOption : " + JsonConvert.SerializeObject(coreOption) + "\notherOptions : " + JsonConvert.SerializeObject(otherOptions));
60
71
  coreOptions = coreOption;
61
72
 
@@ -159,6 +170,7 @@ namespace TapSDK.Core.Standalone
159
170
  {
160
171
  if (TapHttpErrorConstants.ERROR_INVALID_CLIENT.Equals(se.ErrorData.Error))
161
172
  {
173
+ isClientInfoMatched = false;
162
174
  TapLog.Error("Init Failed", se.ErrorData.ErrorDescription);
163
175
  TapMessage.ShowMessage(se.ErrorData.Msg, TapMessage.Position.bottom, TapMessage.Time.twoSecond);
164
176
  }
@@ -184,6 +196,27 @@ namespace TapSDK.Core.Standalone
184
196
  }
185
197
  }
186
198
  }
199
+
200
+ public static bool CheckInitState()
201
+ {
202
+ // 未初始化
203
+ if (coreOptions == null || coreOptions.clientId == null || coreOptions.clientId.Length == 0
204
+ || coreOptions.clientToken == null || coreOptions.clientToken.Length == 0) {
205
+ TapVerifyInitStateUtils.ShowVerifyErrorMsg("当前应用还未初始化","当前应用还未初始化: 请在调用 SDK 业务接口前,先调用 TapTapSDK.Init 接口");
206
+ return false;
207
+ }
208
+ // 应用信息不匹配
209
+ if(isClientInfoMatched == false) {
210
+ TapVerifyInitStateUtils.ShowVerifyErrorMsg("当前应用初始化信息错误","当前应用初始化信息错误: 请在 TapTap 开发者中心检查当前应用调用初始化接口设置的 clientId 、clientToken 是否匹配");
211
+ return false;
212
+ }
213
+ return true;
214
+ }
215
+
216
+ // 获取当前用户设置的 DB userID
217
+ public static string GetCurrentUserId(){
218
+ return User?.Id;
219
+ }
187
220
  }
188
221
 
189
222
  public interface IOpenIDProvider
@@ -21,6 +21,10 @@ namespace TapSDK.Core.Standalone
21
21
  /// <param name="userID">The user ID to set.</param>
22
22
  public void SetUserID(string userID)
23
23
  {
24
+ if (!TapCoreStandalone.CheckInitState())
25
+ {
26
+ return;
27
+ }
24
28
  SetUserID(userID, null);
25
29
  }
26
30
 
@@ -31,6 +35,10 @@ namespace TapSDK.Core.Standalone
31
35
  /// <param name="properties">Additional properties to associate with the user.</param>
32
36
  public void SetUserID(string userID, string properties)
33
37
  {
38
+ if (!TapCoreStandalone.CheckInitState())
39
+ {
40
+ return;
41
+ }
34
42
  if (!IsValidUserID(userID))
35
43
  {
36
44
  TapLogger.Error("Invalid user ID, length should be 1-160 and only contains a-zA-Z0-9_+/=.,:");
@@ -46,6 +54,10 @@ namespace TapSDK.Core.Standalone
46
54
  /// </summary>
47
55
  public void ClearUser()
48
56
  {
57
+ if (!TapCoreStandalone.CheckInitState())
58
+ {
59
+ return;
60
+ }
49
61
  User.Logout();
50
62
  }
51
63
 
@@ -55,6 +67,10 @@ namespace TapSDK.Core.Standalone
55
67
  /// <returns>The device ID.</returns>
56
68
  public string GetDeviceId()
57
69
  {
70
+ if (!TapCoreStandalone.CheckInitState())
71
+ {
72
+ return "";
73
+ }
58
74
  return Identity.DeviceId;
59
75
  }
60
76
 
@@ -65,8 +81,13 @@ namespace TapSDK.Core.Standalone
65
81
  /// <param name="properties">Additional properties to associate with the event.</param>
66
82
  public void LogEvent(string name, string properties)
67
83
  {
84
+ if (!TapCoreStandalone.CheckInitState())
85
+ {
86
+ return;
87
+ }
68
88
  // name 长度256非空,不符合的丢事件,打log
69
- if (!checkLength(name)) {
89
+ if (!checkLength(name))
90
+ {
70
91
  Debug.LogError(name + " Event name length should be less than or equal to 256 characters.");
71
92
  return;
72
93
  }
@@ -80,6 +101,10 @@ namespace TapSDK.Core.Standalone
80
101
  /// <param name="properties">Additional properties to associate with the device initialization.</param>
81
102
  public void DeviceInitialize(string properties)
82
103
  {
104
+ if (!TapCoreStandalone.CheckInitState())
105
+ {
106
+ return;
107
+ }
83
108
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
84
109
  Tracker.TrackDeviceProperties(Constants.PROPERTY_INITIALIZE_TYPE, filterProperties(prop));
85
110
  }
@@ -90,6 +115,10 @@ namespace TapSDK.Core.Standalone
90
115
  /// <param name="properties">Additional properties to associate with the device update.</param>
91
116
  public void DeviceUpdate(string properties)
92
117
  {
118
+ if (!TapCoreStandalone.CheckInitState())
119
+ {
120
+ return;
121
+ }
93
122
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
94
123
  Tracker.TrackDeviceProperties(Constants.PROPERTY_UPDATE_TYPE, filterProperties(prop));
95
124
  }
@@ -100,6 +129,10 @@ namespace TapSDK.Core.Standalone
100
129
  /// <param name="properties">Additional properties to associate with the device addition.</param>
101
130
  public void DeviceAdd(string properties)
102
131
  {
132
+ if (!TapCoreStandalone.CheckInitState())
133
+ {
134
+ return;
135
+ }
103
136
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
104
137
  Tracker.TrackDeviceProperties(Constants.PROPERTY_ADD_TYPE, filterProperties(prop));
105
138
  }
@@ -110,6 +143,10 @@ namespace TapSDK.Core.Standalone
110
143
  /// <param name="properties">Additional properties to associate with the user initialization.</param>
111
144
  public void UserInitialize(string properties)
112
145
  {
146
+ if (!TapCoreStandalone.CheckInitState())
147
+ {
148
+ return;
149
+ }
113
150
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
114
151
  Tracker.TrackUserProperties(Constants.PROPERTY_INITIALIZE_TYPE, filterProperties(prop));
115
152
  }
@@ -120,6 +157,10 @@ namespace TapSDK.Core.Standalone
120
157
  /// <param name="properties">Additional properties to associate with the user update.</param>
121
158
  public void UserUpdate(string properties)
122
159
  {
160
+ if (!TapCoreStandalone.CheckInitState())
161
+ {
162
+ return;
163
+ }
123
164
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
124
165
  Tracker.TrackUserProperties(Constants.PROPERTY_UPDATE_TYPE, filterProperties(prop));
125
166
  }
@@ -130,6 +171,10 @@ namespace TapSDK.Core.Standalone
130
171
  /// <param name="properties">Additional properties to associate with the user addition.</param>
131
172
  public void UserAdd(string properties)
132
173
  {
174
+ if (!TapCoreStandalone.CheckInitState())
175
+ {
176
+ return;
177
+ }
133
178
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
134
179
  Tracker.TrackUserProperties(Constants.PROPERTY_ADD_TYPE, filterProperties(prop));
135
180
  }
@@ -141,11 +186,17 @@ namespace TapSDK.Core.Standalone
141
186
  /// <param name="value">The value of the common property.</param>
142
187
  public void AddCommonProperty(string key, string value)
143
188
  {
144
- if (!checkLength(key)){
189
+ if (!TapCoreStandalone.CheckInitState())
190
+ {
191
+ return;
192
+ }
193
+ if (!checkLength(key))
194
+ {
145
195
  Debug.LogError(key + " Property key length should be less than or equal to 256 characters.");
146
196
  return;
147
197
  }
148
- if (!checkLength(value)){
198
+ if (!checkLength(value))
199
+ {
149
200
  Debug.LogError(value + " Property value length should be less than or equal to 256 characters.");
150
201
  return;
151
202
  }
@@ -158,6 +209,10 @@ namespace TapSDK.Core.Standalone
158
209
  /// <param name="properties">The JSON string containing the common properties.</param>
159
210
  public void AddCommon(string properties)
160
211
  {
212
+ if (!TapCoreStandalone.CheckInitState())
213
+ {
214
+ return;
215
+ }
161
216
  Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
162
217
  Tracker.AddCommon(filterProperties(prop));
163
218
  }
@@ -168,6 +223,10 @@ namespace TapSDK.Core.Standalone
168
223
  /// <param name="key">The key of the common property to clear.</param>
169
224
  public void ClearCommonProperty(string key)
170
225
  {
226
+ if (!TapCoreStandalone.CheckInitState())
227
+ {
228
+ return;
229
+ }
171
230
  Tracker.ClearCommonProperty(key);
172
231
  }
173
232
 
@@ -177,6 +236,10 @@ namespace TapSDK.Core.Standalone
177
236
  /// <param name="keys">The keys of the common properties to clear.</param>
178
237
  public void ClearCommonProperties(string[] keys)
179
238
  {
239
+ if (!TapCoreStandalone.CheckInitState())
240
+ {
241
+ return;
242
+ }
180
243
  Tracker.ClearCommonProperties(keys);
181
244
  }
182
245
 
@@ -185,6 +248,10 @@ namespace TapSDK.Core.Standalone
185
248
  /// </summary>
186
249
  public void ClearAllCommonProperties()
187
250
  {
251
+ if (!TapCoreStandalone.CheckInitState())
252
+ {
253
+ return;
254
+ }
188
255
  Tracker.ClearAllCommonProperties();
189
256
  }
190
257
 
@@ -199,7 +266,12 @@ namespace TapSDK.Core.Standalone
199
266
  /// <param name="properties">Additional properties to associate with the charge event.</param>
200
267
  public void LogChargeEvent(string orderID, string productName, long amount, string currencyType, string paymentMethod, string properties)
201
268
  {
202
- if (amount <= 0 || amount > 100000000000) {
269
+ if (!TapCoreStandalone.CheckInitState())
270
+ {
271
+ return;
272
+ }
273
+ if (amount <= 0 || amount > 100000000000)
274
+ {
203
275
  UnityEngine.Debug.LogError(amount + " is invalid, amount should be in range (0, 100000000000]");
204
276
  return;
205
277
  }
@@ -212,6 +284,10 @@ namespace TapSDK.Core.Standalone
212
284
  /// <param name="callback">The callback function that returns a JSON string containing the dynamic properties.</param>
213
285
  public void RegisterDynamicProperties(Func<string> callback)
214
286
  {
287
+ if (!TapCoreStandalone.CheckInitState())
288
+ {
289
+ return;
290
+ }
215
291
  DynamicProperties dynamicProperties = new DynamicProperties(callback);
216
292
  Tracker.RegisterDynamicPropsDelegate(dynamicProperties);
217
293
  }
@@ -243,9 +319,11 @@ namespace TapSDK.Core.Standalone
243
319
  }
244
320
  }
245
321
 
246
- private bool checkLength(string value){
322
+ private bool checkLength(string value)
323
+ {
247
324
  var maxLength = 256;
248
- if (value.Length <= 0 || value.Length > maxLength){
325
+ if (value.Length <= 0 || value.Length > maxLength)
326
+ {
249
327
  return false;
250
328
  }
251
329
  return true;
@@ -261,19 +339,21 @@ namespace TapSDK.Core.Standalone
261
339
  private Dictionary<string, object> filterProperties(Dictionary<string, object> properties)
262
340
  {
263
341
  Dictionary<string, object> filteredProperties = new Dictionary<string, object>();
264
- foreach (var property in properties)
265
- {
266
- if (property.Key.Length <= 0 || property.Key.Length > 256)
267
- {
268
- Debug.Log(property.Key + " Property key length should be more then 0 and less than or equal to 256 characters.");
269
- continue;
270
- }
271
- if (property.Value.ToString().Length > 256)
342
+ if(properties != null) {
343
+ foreach (var property in properties)
272
344
  {
273
- Debug.Log(property.Value + " Property value length should be less than or equal to 256 characters.");
274
- continue;
345
+ if (property.Key.Length <= 0 || property.Key.Length > 256)
346
+ {
347
+ Debug.Log(property.Key + " Property key length should be more then 0 and less than or equal to 256 characters.");
348
+ continue;
349
+ }
350
+ if (property.Value.ToString().Length > 256)
351
+ {
352
+ Debug.Log(property.Value + " Property value length should be less than or equal to 256 characters.");
353
+ continue;
354
+ }
355
+ filteredProperties.Add(property.Key, property.Value);
275
356
  }
276
- filteredProperties.Add(property.Key, property.Value);
277
357
  }
278
358
  return filteredProperties;
279
359
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "com.taptap.sdk.core",
3
3
  "displayName": "TapTapSDK Core",
4
4
  "description": "TapTapSDK Core",
5
- "version": "4.5.1",
5
+ "version": "4.5.2",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {
package/Plugins.meta DELETED
@@ -1,8 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 9b372fd6a570748ddbf4c96d16ebbc2b
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
package/link.xml DELETED
@@ -1,4 +0,0 @@
1
- <linker>
2
- <assembly fullname="TapSDK.Core.Runtime" preserve="all" />
3
- <assembly fullname="TapSDK.Core.Mobile.Runtime" preserve="all" />
4
- </linker>
package/link.xml.meta DELETED
@@ -1,7 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 1693bce61a5fc4665bf1afd68dbcad8b
3
- TextScriptImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant: