com.taptap.sdk.leaderboard 4.8.1-beta.1 → 4.8.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.
@@ -0,0 +1,60 @@
1
+ using UnityEngine;
2
+ using UnityEditor;
3
+ using UnityEditor.Callbacks;
4
+ # if UNITY_IOS
5
+ using UnityEditor.iOS.Xcode;
6
+ #endif
7
+ using System.IO;
8
+ using System.Collections.Generic;
9
+ using System.Linq;
10
+ using TapSDK.Core.Editor;
11
+ using System.Diagnostics;
12
+
13
+ #if UNITY_IOS
14
+ public class BuildPostProcessor
15
+ {
16
+ [PostProcessBuild(999)]
17
+ public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
18
+ {
19
+ if (buildTarget == BuildTarget.iOS)
20
+ {
21
+ var projPath = TapSDKCoreCompile.GetProjPath(path);
22
+ var proj = TapSDKCoreCompile.ParseProjPath(projPath);
23
+ var target = TapSDKCoreCompile.GetUnityTarget(proj);
24
+
25
+ if (TapSDKCoreCompile.CheckTarget(target))
26
+ {
27
+ UnityEngine.Debug.LogError("Unity-iPhone is NUll");
28
+ return;
29
+ }
30
+ if (TapSDKCoreCompile.HandlerIOSSetting(path,
31
+ Application.dataPath,
32
+ "TapTapLeaderboardResource",
33
+ "com.taptap.sdk.leaderboard",
34
+ "Leaderboard",
35
+ new[] { "TapTapLeaderboardResource.bundle" },
36
+ target, projPath, proj,
37
+ "TapTapLeaderboardSDK"))
38
+ {
39
+ UnityEngine.Debug.Log("TapLeaderboard add Bundle Success!");
40
+ }
41
+ if (TapSDKCoreCompile.HandlerIOSSetting(path,
42
+ Application.dataPath,
43
+ "TapTapProfileResource",
44
+ "com.taptap.sdk.profile",
45
+ "Profile",
46
+ new[] { "TapTapProfileResource.bundle" },
47
+ target, projPath, proj,
48
+ "TapTapProfileSDK"))
49
+ {
50
+ UnityEngine.Debug.Log("TapProfile add Bundle Success!");
51
+ TapSDKCoreCompile.ExecutePodCommand("pod deintegrate && pod install", path);
52
+ return;
53
+ }
54
+
55
+ UnityEngine.Debug.LogWarning("TapLeaderboard add Bundle Failed!");
56
+ }
57
+ }
58
+
59
+ }
60
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 5cd017ff87e60410db626f4d21dbf87d
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,9 +1,15 @@
1
- <?xml version="1.0" ?>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
2
  <dependencies>
3
3
  <androidPackages>
4
4
  <repositories>
5
5
  <repository>https://repo.maven.apache.org/maven2</repository>
6
6
  </repositories>
7
- <androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.8.1-beta.1"/>
7
+ <androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.8.2"/>
8
8
  </androidPackages>
9
+ <iosPods>
10
+ <sources>
11
+ <source>https://github.com/CocoaPods/Specs.git</source>
12
+ </sources>
13
+ <iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapLeaderboardSDK" version="4.8.2"/>
14
+ </iosPods>
9
15
  </dependencies>
@@ -39,16 +39,6 @@ namespace TapSDK.Leaderboard.Mobile
39
39
 
40
40
  public void OpenUserProfile(string openId, string unionId)
41
41
  {
42
- if (string.IsNullOrEmpty(openId))
43
- {
44
- TapLog.Error("OpenUserProfile failed: openId is null or empty.");
45
- return;
46
- }
47
-
48
- if (!string.IsNullOrEmpty(unionId))
49
- {
50
- TapLog.Warning("OpenUserProfile: unionId is not used in mobile platform, it will be ignored.");
51
- }
52
42
  var command = new Command.Builder()
53
43
  .Service(SERVICE_NAME)
54
44
  .Method("openUserProfile")
@@ -58,9 +48,10 @@ namespace TapSDK.Leaderboard.Mobile
58
48
  EngineBridge.GetInstance().CallHandler(command);
59
49
  }
60
50
 
61
- public void SubmitScores(List<SubmitScoresRequest.ScoreItem> scores,
62
- ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
51
+ public Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
63
52
  {
53
+ TapLog.Log("[TapTapLeaderboardImpl] SubmitScores called with Task<SubmitScoresResponse> return type (NEW API)");
54
+ var taskSource = new TaskCompletionSource<SubmitScoresResponse>();
64
55
  var command = new Command.Builder()
65
56
  .Service(SERVICE_NAME)
66
57
  .Method("submitScores")
@@ -70,50 +61,59 @@ namespace TapSDK.Leaderboard.Mobile
70
61
  .CommandBuilder();
71
62
  EngineBridge.GetInstance().CallHandler(command, result =>
72
63
  {
73
- if (result.code != Result.RESULT_SUCCESS)
74
- {
75
- return;
76
- }
77
-
78
- if (string.IsNullOrEmpty(result.content))
64
+ try
79
65
  {
80
- return;
66
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
67
+ {
68
+ taskSource.TrySetException(new TapException(-1, "Failed to submit scores: code=" + result.code + " content=" + result.content));
69
+ return;
70
+ }
71
+
72
+ TapLog.Log("SubmitScores, result ==>>> " + JsonConvert.SerializeObject(result));
73
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
74
+ var status = SafeDictionary.GetValue<string>(dic, "status");
75
+ switch (status)
76
+ {
77
+ case "success":
78
+ var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
79
+ TapLog.Log("submit scores success: " + jsonStr);
80
+ var data = JsonConvert.DeserializeObject<SubmitScoresResponse>(jsonStr);
81
+ if (data != null)
82
+ {
83
+ taskSource.TrySetResult(data);
84
+ }
85
+ else
86
+ {
87
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
88
+ }
89
+ break;
90
+ case "failure":
91
+ var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
92
+ var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
93
+ TapLog.Log("failed to submit scores, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
94
+ taskSource.TrySetException(new TapException(errorCode, errorMsg));
95
+ break;
96
+ default:
97
+ taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
98
+ break;
99
+ }
81
100
  }
82
-
83
- TapLog.Log("SubmitScores, result ==>>> " + JsonConvert.SerializeObject(result));
84
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
85
- var status = SafeDictionary.GetValue<string>(dic, "status");
86
- switch (status)
101
+ catch (Exception e)
87
102
  {
88
- case "success":
89
- var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
90
- TapLog.Log("submit scores success: " + jsonStr);
91
- var data = JsonConvert.DeserializeObject<SubmitScoresResponse>(jsonStr);
92
- if (callback != null)
93
- {
94
- callback.OnSuccess(data);
95
- }
96
- break;
97
- case "failure":
98
- var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
99
- var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
100
- TapLog.Log("failed to submit scores, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
101
- if (callback != null)
102
- {
103
- callback.OnFailure(errorCode, errorMsg);
104
- }
105
- break;
103
+ taskSource.TrySetException(new TapException(-1, "Failed to submit scores: error=" + e.Message + ", content=" + result.content));
106
104
  }
107
105
  });
106
+ return taskSource.Task;
108
107
  }
109
108
 
110
- public void LoadLeaderboardScores(
109
+ public Task<LeaderboardScoreResponse> LoadLeaderboardScores(
111
110
  string leaderboardId,
112
111
  string leaderboardCollection,
113
112
  string nextPage,
114
- string periodToken,
115
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
113
+ string periodToken)
116
114
  {
115
+ TapLog.Log("[TapTapLeaderboardImpl] LoadLeaderboardScores called with Task<LeaderboardScoreResponse> return type (NEW API)");
116
+ var taskSource = new TaskCompletionSource<LeaderboardScoreResponse>();
117
117
  var command = new Command.Builder()
118
118
  .Service(SERVICE_NAME)
119
119
  .Method("loadLeaderboardScores")
@@ -121,106 +121,128 @@ namespace TapSDK.Leaderboard.Mobile
121
121
  .Args("leaderboardCollection", leaderboardCollection)
122
122
  .Args("nextPage", nextPage)
123
123
  .Args("periodToken", periodToken)
124
+ .Callback(true)
125
+ .OnceTime(true)
124
126
  .CommandBuilder();
125
127
 
126
128
  EngineBridge.GetInstance().CallHandler(command, result =>
127
129
  {
128
- if (result.code != Result.RESULT_SUCCESS)
129
- {
130
- return;
131
- }
132
-
133
- if (string.IsNullOrEmpty(result.content))
130
+ try
134
131
  {
135
- return;
132
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
133
+ {
134
+ taskSource.TrySetException(new TapException(-1, "Failed to load leaderboard scores: code=" + result.code + " content=" + result.content));
135
+ return;
136
+ }
137
+
138
+ TapLog.Log("LoadLeaderboardScores, result ==>>> " + JsonConvert.SerializeObject(result));
139
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
140
+ var status = SafeDictionary.GetValue<string>(dic, "status");
141
+ switch (status)
142
+ {
143
+ case "success":
144
+ var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
145
+ TapLog.Log("load leaderboard scores success: " + jsonStr);
146
+ var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
147
+ if (data != null)
148
+ {
149
+ taskSource.TrySetResult(data);
150
+ }
151
+ else
152
+ {
153
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
154
+ }
155
+ break;
156
+ case "failure":
157
+ var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
158
+ var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
159
+ TapLog.Log("load leaderboard scores failed, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
160
+ taskSource.TrySetException(new TapException(errorCode, errorMsg));
161
+ break;
162
+ default:
163
+ taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
164
+ break;
165
+ }
136
166
  }
137
-
138
- TapLog.Log("LoadLeaderboardScores, result ==>>> " + JsonConvert.SerializeObject(result));
139
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
140
- var status = SafeDictionary.GetValue<string>(dic, "status");
141
- switch (status)
167
+ catch (Exception e)
142
168
  {
143
- case "success":
144
- var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
145
- TapLog.Log("load leaderboard scores success: " + jsonStr);
146
- var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
147
- if (callback != null)
148
- {
149
- callback.OnSuccess(data);
150
- }
151
- break;
152
- case "failure":
153
- var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
154
- var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
155
- TapLog.Log("load leaderboard scores failed, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
156
- if (callback != null)
157
- {
158
- callback.OnFailure(errorCode, errorMsg);
159
- }
160
- break;
169
+ taskSource.TrySetException(new TapException(-1, "Failed to load leaderboard scores: error=" + e.Message + ", content=" + result.content));
161
170
  }
162
171
  });
172
+ return taskSource.Task;
163
173
  }
164
174
 
165
- public void LoadCurrentPlayerLeaderboardScore(
175
+ public Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(
166
176
  string leaderboardId,
167
177
  string leaderboardCollection,
168
- string periodToken,
169
- ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
178
+ string periodToken)
170
179
  {
180
+ TapLog.Log("[TapTapLeaderboardImpl] LoadCurrentPlayerLeaderboardScore called with Task<UserScoreResponse> return type (NEW API)");
181
+ var taskSource = new TaskCompletionSource<UserScoreResponse>();
171
182
  var command = new Command.Builder()
172
183
  .Service(SERVICE_NAME)
173
184
  .Method("loadCurrentPlayerLeaderboardScore")
174
185
  .Args("leaderboardId", leaderboardId)
175
186
  .Args("leaderboardCollection", leaderboardCollection)
176
187
  .Args("periodToken", periodToken)
188
+ .Callback(true)
189
+ .OnceTime(true)
177
190
  .CommandBuilder();
178
191
  EngineBridge.GetInstance().CallHandler(command, result =>
179
192
  {
180
- if (result.code != Result.RESULT_SUCCESS)
181
- {
182
- return;
183
- }
184
-
185
- if (string.IsNullOrEmpty(result.content))
193
+ try
186
194
  {
187
- return;
195
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
196
+ {
197
+ taskSource.TrySetException(new TapException(-1, "Failed to load current player leaderboard score: code=" + result.code + " content=" + result.content));
198
+ return;
199
+ }
200
+
201
+ TapLog.Log("LoadCurrentPlayerLeaderboardScore, result ==>>> " + JsonConvert.SerializeObject(result));
202
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
203
+ var status = SafeDictionary.GetValue<string>(dic, "status");
204
+ switch (status)
205
+ {
206
+ case "success":
207
+ var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
208
+ TapLog.Log("Load current player leaderboard score success: " + jsonStr);
209
+ var data = JsonConvert.DeserializeObject<UserScoreResponse>(jsonStr);
210
+ if (data != null)
211
+ {
212
+ taskSource.TrySetResult(data);
213
+ }
214
+ else
215
+ {
216
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
217
+ }
218
+ break;
219
+ case "failure":
220
+ var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
221
+ var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
222
+ TapLog.Log("Load current player leaderboard score failed: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
223
+ taskSource.TrySetException(new TapException(errorCode, errorMsg));
224
+ break;
225
+ default:
226
+ taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
227
+ break;
228
+ }
188
229
  }
189
-
190
- TapLog.Log("LoadCurrentPlayerLeaderboardScore, result ==>>> " + JsonConvert.SerializeObject(result));
191
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
192
- var status = SafeDictionary.GetValue<string>(dic, "status");
193
- switch (status)
230
+ catch (Exception e)
194
231
  {
195
- case "success":
196
- var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
197
- TapLog.Log("Load current player leaderboard score success: " + jsonStr);
198
- var data = JsonConvert.DeserializeObject<UserScoreResponse>(jsonStr);
199
- if (callback != null)
200
- {
201
- callback.OnSuccess(data);
202
- }
203
- break;
204
- case "failure":
205
- var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
206
- var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
207
- TapLog.Log("Load current player leaderboard score failed: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
208
- if (callback != null)
209
- {
210
- callback.OnFailure(errorCode, errorMsg);
211
- }
212
- break;
232
+ taskSource.TrySetException(new TapException(-1, "Failed to load current player leaderboard score: error=" + e.Message + ", content=" + result.content));
213
233
  }
214
234
  });
235
+ return taskSource.Task;
215
236
  }
216
237
 
217
- public void LoadPlayerCenteredScores(
238
+ public Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(
218
239
  string leaderboardId,
219
240
  string leaderboardCollection,
220
241
  string periodToken,
221
- int? maxCount,
222
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
242
+ int? maxCount)
223
243
  {
244
+ TapLog.Log("[TapTapLeaderboardImpl] LoadPlayerCenteredScores called with Task<LeaderboardScoreResponse> return type (NEW API)");
245
+ var taskSource = new TaskCompletionSource<LeaderboardScoreResponse>();
224
246
  var command = new Command.Builder()
225
247
  .Service(SERVICE_NAME)
226
248
  .Method("loadPlayerCenteredScores")
@@ -228,44 +250,54 @@ namespace TapSDK.Leaderboard.Mobile
228
250
  .Args("leaderboardCollection", leaderboardCollection)
229
251
  .Args("periodToken", periodToken)
230
252
  .Args("maxCount", maxCount)
253
+ .Callback(true)
254
+ .OnceTime(true)
231
255
  .CommandBuilder();
232
256
  EngineBridge.GetInstance().CallHandler(command, result =>
233
257
  {
234
- if (result.code != Result.RESULT_SUCCESS)
258
+ try
235
259
  {
236
- return;
237
- }
238
-
239
- if (string.IsNullOrEmpty(result.content))
240
- {
241
- return;
260
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
261
+ {
262
+ taskSource.TrySetException(new TapException(-1, "Failed to load player centered scores: code=" + result.code + " content=" + result.content));
263
+ return;
264
+ }
265
+
266
+ TapLog.Log("LoadPlayerCenteredScores, result ==>>> " + JsonConvert.SerializeObject(result));
267
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
268
+ var status = SafeDictionary.GetValue<string>(dic, "status");
269
+ switch (status)
270
+ {
271
+ case "success":
272
+ var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
273
+ TapLog.Log("Load player centered scores success: " + jsonStr);
274
+ var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
275
+ if (data != null)
276
+ {
277
+ taskSource.TrySetResult(data);
278
+ }
279
+ else
280
+ {
281
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
282
+ }
283
+ break;
284
+ case "failure":
285
+ var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
286
+ var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
287
+ TapLog.Log("Load failed load player centered scores:: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
288
+ taskSource.TrySetException(new TapException(errorCode, errorMsg));
289
+ break;
290
+ default:
291
+ taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
292
+ break;
293
+ }
242
294
  }
243
-
244
- TapLog.Log("LoadPlayerCenteredScores, result ==>>> " + JsonConvert.SerializeObject(result));
245
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
246
- var status = SafeDictionary.GetValue<string>(dic, "status");
247
- switch (status)
295
+ catch (Exception e)
248
296
  {
249
- case "success":
250
- var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
251
- TapLog.Log("Load player centered scores success: " + jsonStr);
252
- var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
253
- if (callback != null)
254
- {
255
- callback.OnSuccess(data);
256
- }
257
- break;
258
- case "failure":
259
- var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
260
- var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
261
- TapLog.Log("Load failed load player centered scores:: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
262
- if (callback != null)
263
- {
264
- callback.OnFailure(errorCode, errorMsg);
265
- }
266
- break;
297
+ taskSource.TrySetException(new TapException(-1, "Failed to load player centered scores: error=" + e.Message + ", content=" + result.content));
267
298
  }
268
299
  });
300
+ return taskSource.Task;
269
301
  }
270
302
 
271
303
  public void SetShareCallback(ITapTapLeaderboardShareCallback callback)
@@ -333,28 +365,61 @@ namespace TapSDK.Leaderboard.Mobile
333
365
  .CommandBuilder();
334
366
  EngineBridge.GetInstance().CallHandler(command, (result) =>
335
367
  {
336
- if (result.code != Result.RESULT_SUCCESS)
368
+ try
337
369
  {
338
- return;
339
- }
370
+ if (result.code != Result.RESULT_SUCCESS)
371
+ {
372
+ TapLog.Log("InitRegisterCallBack failed with code: " + result.code);
373
+ return;
374
+ }
340
375
 
341
- if (string.IsNullOrEmpty(result.content))
342
- {
343
- return;
376
+ if (string.IsNullOrEmpty(result.content))
377
+ {
378
+ TapLog.Log("InitRegisterCallBack result content is empty");
379
+ return;
380
+ }
381
+
382
+ TapLog.Log("InitRegisterCallBack result content: " + result.content);
383
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
384
+ var status = SafeDictionary.GetValue<string>(dic, "status");
385
+ switch (status)
386
+ {
387
+ case "success":
388
+ // Fix: data is already an object, not a string that needs deserialization
389
+ var dataDic = SafeDictionary.GetValue<Dictionary<string, object>>(dic, "data");
390
+ if (dataDic != null)
391
+ {
392
+ var code = SafeDictionary.GetValue<int>(dataDic, "code");
393
+ var message = SafeDictionary.GetValue<string>(dataDic, "message");
394
+ TapLog.Log("InitRegisterCallBack callback result - code: " + code + ", message: " + message);
395
+ foreach (var callback in callbacks)
396
+ {
397
+ callback.OnLeaderboardResult(code, message);
398
+ }
399
+ }
400
+ else
401
+ {
402
+ TapLog.Log("InitRegisterCallBack data field is null or invalid");
403
+ }
404
+ break;
405
+
406
+ case "failure":
407
+ var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
408
+ var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
409
+ TapLog.Log("InitRegisterCallBack failed - errorCode: " + errorCode + ", errorMsg: " + errorMsg);
410
+ foreach (var callback in callbacks)
411
+ {
412
+ callback.OnLeaderboardResult(errorCode, errorMsg);
413
+ }
414
+ break;
415
+ default:
416
+ TapLog.Log("InitRegisterCallBack unknown status: " + status);
417
+ break;
418
+ }
344
419
  }
345
-
346
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
347
- var status = SafeDictionary.GetValue<string>(dic, "status");
348
- switch (status)
420
+ catch (Exception e)
349
421
  {
350
- case "failure":
351
- var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
352
- var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
353
- foreach (var callback in callbacks)
354
- {
355
- callback.OnLeaderboardResult(errorCode, errorMsg);
356
- }
357
- break;
422
+ TapLog.Log("InitRegisterCallBack exception: " + e.Message + ", content: " + result.content);
358
423
  }
359
424
  });
360
425
  }
@@ -1,4 +1,5 @@
1
1
  using System.Collections.Generic;
2
+ using System.Threading.Tasks;
2
3
  using TapSDK.Core.Internal.Utils;
3
4
 
4
5
  namespace TapSDK.Leaderboard.Runtime.Internal
@@ -24,35 +25,33 @@ namespace TapSDK.Leaderboard.Runtime.Internal
24
25
  public void OpenLeaderboard(string leaderboardId, string collection) =>
25
26
  _platform.OpenLeaderboard(leaderboardId, collection);
26
27
 
27
- public void SubmitScores(List<SubmitScoresRequest.ScoreItem> scores,
28
- ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
28
+ public Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
29
29
  {
30
- _platform.SubmitScores(scores, callback);
30
+ return _platform.SubmitScores(scores);
31
31
  }
32
32
 
33
- public void LoadLeaderboardScores(
33
+ public Task<LeaderboardScoreResponse> LoadLeaderboardScores(
34
34
  string leaderboardId,
35
35
  string leaderboardCollection,
36
36
  string nextPage,
37
- string periodToken,
38
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback) =>
39
- _platform.LoadLeaderboardScores(leaderboardId, leaderboardCollection, nextPage, periodToken, callback);
37
+ string periodToken)
38
+ {
39
+ return _platform.LoadLeaderboardScores(leaderboardId, leaderboardCollection, nextPage, periodToken);
40
+ }
40
41
 
41
- public void LoadCurrentPlayerLeaderboardScore(string leaderboardId,
42
+ public Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(string leaderboardId,
42
43
  string leaderboardCollection,
43
- string periodToken,
44
- ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
44
+ string periodToken)
45
45
  {
46
- _platform.LoadCurrentPlayerLeaderboardScore(leaderboardId, leaderboardCollection, periodToken, callback);
46
+ return _platform.LoadCurrentPlayerLeaderboardScore(leaderboardId, leaderboardCollection, periodToken);
47
47
  }
48
48
 
49
- public void LoadPlayerCenteredScores(string leaderboardId,
49
+ public Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(string leaderboardId,
50
50
  string leaderboardCollection,
51
51
  string periodToken,
52
- int? maxCount,
53
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
52
+ int? maxCount)
54
53
  {
55
- _platform.LoadPlayerCenteredScores(leaderboardId, leaderboardCollection, periodToken, maxCount, callback);
54
+ return _platform.LoadPlayerCenteredScores(leaderboardId, leaderboardCollection, periodToken, maxCount);
56
55
  }
57
56
 
58
57
  public void RegisterLeaderboardCallback(ITapTapLeaderboardCallback callback)
@@ -1,4 +1,5 @@
1
1
  using System.Collections.Generic;
2
+ using System.Threading.Tasks;
2
3
 
3
4
  namespace TapSDK.Leaderboard
4
5
  {
@@ -25,9 +26,8 @@ namespace TapSDK.Leaderboard
25
26
  /// 提交分数
26
27
  /// </summary>
27
28
  /// <param name="scores">分数列表</param>
28
- /// <param name="callback">回调</param>
29
- void SubmitScores(List<SubmitScoresRequest.ScoreItem> scores,
30
- ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback);
29
+ /// <returns>提交结果</returns>
30
+ Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores);
31
31
 
32
32
  /// <summary>
33
33
  /// 加载排行榜分数
@@ -36,13 +36,12 @@ namespace TapSDK.Leaderboard
36
36
  /// <param name="leaderboardCollection">排行榜集合类型</param>
37
37
  /// <param name="nextPage">下一页标识</param>
38
38
  /// <param name="periodToken">周期标识</param>
39
- /// <param name="callback">回调</param>
40
- void LoadLeaderboardScores(
39
+ /// <returns>排行榜分数结果</returns>
40
+ Task<LeaderboardScoreResponse> LoadLeaderboardScores(
41
41
  string leaderboardId,
42
42
  string leaderboardCollection,
43
43
  string nextPage,
44
- string periodToken,
45
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback);
44
+ string periodToken);
46
45
 
47
46
  /// <summary>
48
47
  /// 加载当前玩家排行榜分数
@@ -50,11 +49,10 @@ namespace TapSDK.Leaderboard
50
49
  /// <param name="leaderboardId">排行榜ID</param>
51
50
  /// <param name="leaderboardCollection">排行榜集合类型</param>
52
51
  /// <param name="periodToken">周期标识</param>
53
- /// <param name="callback">回调</param>
54
- void LoadCurrentPlayerLeaderboardScore(string leaderboardId,
52
+ /// <returns>用户分数结果</returns>
53
+ Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(string leaderboardId,
55
54
  string leaderboardCollection,
56
- string periodToken,
57
- ITapTapLeaderboardResponseCallback<UserScoreResponse> callback);
55
+ string periodToken);
58
56
 
59
57
  /// <summary>
60
58
  /// 加载以玩家为中心的分数
@@ -63,12 +61,11 @@ namespace TapSDK.Leaderboard
63
61
  /// <param name="leaderboardCollection">排行榜集合类型</param>
64
62
  /// <param name="periodToken">周期标识</param>
65
63
  /// <param name="maxCount">最大数量</param>
66
- /// <param name="callback">回调</param>
67
- void LoadPlayerCenteredScores(string leaderboardId,
64
+ /// <returns>排行榜分数结果</returns>
65
+ Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(string leaderboardId,
68
66
  string leaderboardCollection,
69
67
  string periodToken,
70
- int? maxCount,
71
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback);
68
+ int? maxCount);
72
69
 
73
70
  /// <summary>
74
71
  /// 设置分享回调
@@ -13,7 +13,7 @@ namespace TapSDK.Leaderboard
13
13
  /// <summary>
14
14
  /// SDK版本号
15
15
  /// </summary>
16
- public static readonly string Version = "4.8.1-beta.1";
16
+ public static readonly string Version = "4.8.2";
17
17
 
18
18
  /// <summary>
19
19
  /// 打开排行榜页面
@@ -39,11 +39,10 @@ namespace TapSDK.Leaderboard
39
39
  /// 批量提交用户排行榜分数(一次最多提交5个分数)
40
40
  /// </summary>
41
41
  /// <param name="scores">分数列表</param>
42
- /// <param name="callback">回调</param>
43
- public static void SubmitScores(List<SubmitScoresRequest.ScoreItem> scores,
44
- ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
42
+ /// <returns>提交结果</returns>
43
+ public static Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
45
44
  {
46
- TapTapLeaderboardManager.Instance.SubmitScores(scores, callback);
45
+ return TapTapLeaderboardManager.Instance.SubmitScores(scores);
47
46
  }
48
47
 
49
48
  /// <summary>
@@ -53,20 +52,18 @@ namespace TapSDK.Leaderboard
53
52
  /// <param name="leaderboardCollection">排行榜集合</param>
54
53
  /// <param name="nextPage">下一页标识</param>
55
54
  /// <param name="periodToken">周期标识</param>
56
- /// <param name="callback">回调</param>
57
- public static void LoadLeaderboardScores(
55
+ /// <returns>排行榜分数结果</returns>
56
+ public static Task<LeaderboardScoreResponse> LoadLeaderboardScores(
58
57
  string leaderboardId,
59
58
  string leaderboardCollection,
60
59
  string nextPage,
61
- string periodToken,
62
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
60
+ string periodToken)
63
61
  {
64
- TapTapLeaderboardManager.Instance.LoadLeaderboardScores(
62
+ return TapTapLeaderboardManager.Instance.LoadLeaderboardScores(
65
63
  leaderboardId,
66
64
  leaderboardCollection,
67
65
  nextPage,
68
- periodToken,
69
- callback
66
+ periodToken
70
67
  );
71
68
  }
72
69
 
@@ -76,18 +73,16 @@ namespace TapSDK.Leaderboard
76
73
  /// <param name="leaderboardId">排行榜ID</param>
77
74
  /// <param name="leaderboardCollection">排行榜集合</param>
78
75
  /// <param name="periodToken">周期标识</param>
79
- /// <param name="callback">回调</param>
80
- public static void LoadCurrentPlayerLeaderboardScore(
76
+ /// <returns>用户分数结果</returns>
77
+ public static Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(
81
78
  string leaderboardId,
82
79
  string leaderboardCollection,
83
- string periodToken,
84
- ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
80
+ string periodToken)
85
81
  {
86
- TapTapLeaderboardManager.Instance.LoadCurrentPlayerLeaderboardScore(
82
+ return TapTapLeaderboardManager.Instance.LoadCurrentPlayerLeaderboardScore(
87
83
  leaderboardId,
88
84
  leaderboardCollection,
89
- periodToken,
90
- callback
85
+ periodToken
91
86
  );
92
87
  }
93
88
 
@@ -98,20 +93,18 @@ namespace TapSDK.Leaderboard
98
93
  /// <param name="leaderboardCollection">排行榜集合</param>
99
94
  /// <param name="periodToken">周期标识</param>
100
95
  /// <param name="maxCount">最大数量,-1表示不限制</param>
101
- /// <param name="callback">回调</param>
102
- public static void LoadPlayerCenteredScores(
96
+ /// <returns>排行榜分数结果</returns>
97
+ public static Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(
103
98
  string leaderboardId,
104
99
  string leaderboardCollection,
105
100
  string periodToken,
106
- int? maxCount,
107
- ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
101
+ int? maxCount)
108
102
  {
109
- TapTapLeaderboardManager.Instance.LoadPlayerCenteredScores(
103
+ return TapTapLeaderboardManager.Instance.LoadPlayerCenteredScores(
110
104
  leaderboardId,
111
105
  leaderboardCollection,
112
106
  periodToken,
113
- maxCount,
114
- callback
107
+ maxCount
115
108
  );
116
109
  }
117
110
 
package/package.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "com.taptap.sdk.leaderboard",
3
3
  "displayName": "TapTapSDK Leaderboard",
4
4
  "description": "TapTapSDK Leaderboard",
5
- "version": "4.8.1-beta.1",
5
+ "version": "4.8.2",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.taptap.sdk.core": "4.8.1-beta.1",
10
- "com.taptap.sdk.login": "4.8.1-beta.1"
9
+ "com.taptap.sdk.core": "4.8.2",
10
+ "com.taptap.sdk.login": "4.8.2"
11
11
  }
12
12
  }