com.xd.sdk.account 0.0.10-alpha → 0.0.13-alpha

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,32 @@
1
+ fileFormatVersion: 2
2
+ guid: c384e2e57d3c54ea79502c23b2a03280
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
13
+ platformData:
14
+ - first:
15
+ Android: Android
16
+ second:
17
+ enabled: 1
18
+ settings: {}
19
+ - first:
20
+ Any:
21
+ second:
22
+ enabled: 0
23
+ settings: {}
24
+ - first:
25
+ Editor: Editor
26
+ second:
27
+ enabled: 0
28
+ settings:
29
+ DefaultValueInitialized: true
30
+ userData:
31
+ assetBundleName:
32
+ assetBundleVariant:
@@ -6,4 +6,4 @@
6
6
  //
7
7
  #define XDGAccount_VERSION @"7.0.0"
8
8
  #define XDSAccount_VERSION_CODE @"7000000"
9
- // HASH 7f0303a
9
+ // HASH 8bd7e79
@@ -66,13 +66,13 @@ namespace XD.SDK.Account.Internal.Mobile
66
66
  private AccountFeaturesImpl()
67
67
  {
68
68
  EngineBridge.GetInstance()
69
- .Register(BridgeConstants.Account.SERVICE_NAME, BridgeConstants.Account.SERVICE_IMPL);
69
+ .Register(BridgeConstants.Account.ServiceName, BridgeConstants.Account.ServiceImpl);
70
70
  }
71
71
 
72
72
  public void AddUserStatusChangeCallback(Action<XDGUserStatusCodeType, string> callback)
73
73
  {
74
74
  var command = new Command.Builder()
75
- .Service(BridgeConstants.Account.BRIDGE_NAME)
75
+ .Service(BridgeConstants.Account.BridgeName)
76
76
  .Method("addUserStatusChangeCallback")
77
77
  .Callback(true)
78
78
  .OnceTime(false)
@@ -94,7 +94,7 @@ namespace XD.SDK.Account.Internal.Mobile
94
94
  public void LoginByType(LoginType loginType, Action<XDGUser> callback, Action<XDGError> errorCallback)
95
95
  {
96
96
  var command = new Command.Builder()
97
- .Service(BridgeConstants.Account.BRIDGE_NAME)
97
+ .Service(BridgeConstants.Account.BridgeName)
98
98
  .Method("loginByType")
99
99
  .Args("loginType", loginType.FormatString()) //和app交互用的是字符串,如TapTap
100
100
  .Callback(true)
@@ -124,6 +124,7 @@ namespace XD.SDK.Account.Internal.Mobile
124
124
  {
125
125
  XDGEventBus.Publish(XDGEvents.TdsSDKRefreshFacebookTime);
126
126
  }
127
+
127
128
  callback(user);
128
129
  return;
129
130
  }
@@ -141,7 +142,7 @@ namespace XD.SDK.Account.Internal.Mobile
141
142
  public void Logout()
142
143
  {
143
144
  var command = new Command.Builder()
144
- .Service(BridgeConstants.Account.BRIDGE_NAME)
145
+ .Service(BridgeConstants.Account.BridgeName)
145
146
  .Method("logout")
146
147
  .Callback(false)
147
148
  .OnceTime(true)
@@ -154,7 +155,7 @@ namespace XD.SDK.Account.Internal.Mobile
154
155
  XDGUser resultUser = null;
155
156
  string currentUserString = null;
156
157
  #if UNITY_ANDROID
157
- using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.SERVICE_IMPL))
158
+ using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.BridgeStaticImpl))
158
159
  {
159
160
  currentUserString = accountBridgeClass.CallStatic<string>("getCurrentUser");
160
161
  }
@@ -185,7 +186,7 @@ namespace XD.SDK.Account.Internal.Mobile
185
186
  public void OpenCustomerService(XDGRoleInfo roleInfo, string path, Dictionary<string, object> paramsMap)
186
187
  {
187
188
  var command = new Command.Builder()
188
- .Service(BridgeConstants.Account.BRIDGE_NAME)
189
+ .Service(BridgeConstants.Account.BridgeName)
189
190
  .Method("openCustomerService")
190
191
  .Args(XDUtility.BridgeArgToDictionary("openCustomerService", roleInfo))
191
192
  .Args("path", path)
@@ -199,7 +200,7 @@ namespace XD.SDK.Account.Internal.Mobile
199
200
  public void OpenUserCenter()
200
201
  {
201
202
  var command = new Command.Builder()
202
- .Service(BridgeConstants.Account.BRIDGE_NAME)
203
+ .Service(BridgeConstants.Account.BridgeName)
203
204
  .Method("openUserCenter")
204
205
  .Callback(false)
205
206
  .OnceTime(true)
@@ -210,7 +211,7 @@ namespace XD.SDK.Account.Internal.Mobile
210
211
  public void OpenUserDashboard(XDGRoleInfo roleInfo)
211
212
  {
212
213
  var command = new Command.Builder()
213
- .Service(BridgeConstants.Account.BRIDGE_NAME)
214
+ .Service(BridgeConstants.Account.BridgeName)
214
215
  .Method("openUserDashboard")
215
216
  .Args(XDUtility.BridgeArgToDictionary("openUserDashboard", roleInfo))
216
217
  .Callback(false)
@@ -222,7 +223,7 @@ namespace XD.SDK.Account.Internal.Mobile
222
223
  public void OpenAccountDeletion()
223
224
  {
224
225
  var command = new Command.Builder()
225
- .Service(BridgeConstants.Account.BRIDGE_NAME)
226
+ .Service(BridgeConstants.Account.BridgeName)
226
227
  .Method("openAccountDeletion")
227
228
  .Callback(false)
228
229
  .OnceTime(true)
@@ -233,7 +234,7 @@ namespace XD.SDK.Account.Internal.Mobile
233
234
  public void BindByType(LoginType loginType, Action<bool, XDGError> callback)
234
235
  {
235
236
  var command = new Command.Builder()
236
- .Service(BridgeConstants.Account.BRIDGE_NAME)
237
+ .Service(BridgeConstants.Account.BridgeName)
237
238
  .Method("bindByType")
238
239
  .Args("bindByType", loginType.FormatString())
239
240
  .Callback(true)
@@ -264,9 +265,9 @@ namespace XD.SDK.Account.Internal.Mobile
264
265
  var method = request.Method.ToString().ToUpper();
265
266
  var authorization = "";
266
267
  #if UNITY_ANDROID
267
- using (var AccountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.SERVICE_IMPL))
268
+ using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.BridgeStaticImpl))
268
269
  {
269
- authorization = AccountBridgeClass.CallStatic<string>("getRequestAuthorizationHeaderString", url, method, timestamp);
270
+ authorization = accountBridgeClass.CallStatic<string>("getRequestAuthorizationHeaderString", url, method, timestamp);
270
271
  }
271
272
  #elif UNITY_IOS
272
273
  IntPtr ptr = XDAccountBridgeGetAuthorization(url, method, timestamp);
@@ -298,7 +299,8 @@ namespace XD.SDK.Account.Internal.Mobile
298
299
  return;
299
300
  }
300
301
 
301
- // XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
302
+ //TODO 同步之前先退登 TDSUser
303
+ XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
302
304
  var response = await HttpClient.PostAsync<LoginSyncResponse>(LoginSynUrl);
303
305
  var sessionToken = XDDictionary.GetValue<string>(response.Data, "sessionToken");
304
306
  if (string.IsNullOrEmpty(sessionToken))
@@ -306,7 +308,6 @@ namespace XD.SDK.Account.Internal.Mobile
306
308
  XDGLogger.Warn("[SyncTDSUser] sessionToken is Null!");
307
309
  return;
308
310
  }
309
-
310
311
  XDGEventBus.Publish(XDGEvents.TdsSDKSyncUser, sessionToken, user.UserId);
311
312
  }
312
313
  catch (Exception e)
@@ -318,7 +319,7 @@ namespace XD.SDK.Account.Internal.Mobile
318
319
  private void RefreshFacebookToken()
319
320
  {
320
321
  #if UNITY_ANDROID
321
- using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.SERVICE_IMPL))
322
+ using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.BridgeStaticImpl))
322
323
  {
323
324
  var fbToken = accountBridgeClass.CallStatic<string>("getFacebookToken");
324
325
  XDGLogger.Debug($"[GetFacebookToken] fbToken:{fbToken}");
@@ -328,7 +329,6 @@ namespace XD.SDK.Account.Internal.Mobile
328
329
  XDGLogger.Warn($"[GetFacebookToken] error:{JsonConvert.SerializeObject(tokenDic)}");
329
330
  return;
330
331
  }
331
-
332
332
  var token = XDDictionary.GetValue<string>(tokenDic, "access_token");
333
333
  var userId = XDDictionary.GetValue<string>(tokenDic, "userID");
334
334
  XDGEventBus.Publish(XDGEvents.TdsSDKSyncFacebookToken, token, userId);
@@ -44,7 +44,6 @@ namespace XD.SDK.Account.Internal.Standalone
44
44
  {
45
45
  }
46
46
 
47
-
48
47
  internal static Action<XDGUserStatusCodeType, string> UserStatusChangeCallback;
49
48
 
50
49
  public void AddUserStatusChangeCallback(Action<XDGUserStatusCodeType, string> callback)
@@ -240,9 +239,10 @@ namespace XD.SDK.Account.Internal.Standalone
240
239
  AliyunTrack.LoginAntiAddictionStartup();
241
240
  var complianceResult =
242
241
  await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKComplianceStartup, ConfigModule.IsGlobal, user.UserId);
243
- AliyunTrack.LoginAntiAddictionResult(XDDictionary.GetValue<int>(complianceResult, "code", -100),
244
- XDDictionary.GetValue<string>(complianceResult, "reason"),
245
- XDDictionary.GetValue<string>(complianceResult, "extras"));
242
+ // TODO 统一走回调进行埋点
243
+ // AliyunTrack.LoginAntiAddictionResult(XDDictionary.GetValue(complianceResult, "code", -100),
244
+ // XDDictionary.GetValue<string>(complianceResult, "reason"),
245
+ // XDDictionary.GetValue<string>(complianceResult, "extras"));
246
246
  if (XDDictionary.GetValue<bool>(complianceResult, "success"))
247
247
  {
248
248
  await AgreementModule.SignAgreement(user.UserId);
@@ -256,7 +256,7 @@ namespace XD.SDK.Account.Internal.Standalone
256
256
  {
257
257
  if ((e.HttpStatusCode == 401 && loginType == LoginType.Default) || e.Code == 40311 || e.Code == 40312)
258
258
  {
259
- InternalLogout(false);
259
+ InternalLogout("LOGOUT_API", false);
260
260
  }
261
261
 
262
262
  var errorMsg = e.Message;
@@ -273,27 +273,33 @@ namespace XD.SDK.Account.Internal.Standalone
273
273
  }
274
274
  }
275
275
 
276
- internal static void InternalLogout(bool needNotify = true)
276
+ public void InternalLogout(string logoutType = "LOGOUT_API", bool needNotify = true, bool bShowAgreement = true)
277
277
  {
278
278
  // SDK 登陆成功
279
- AliyunTrack.LoginLogout("LOGOUT_API");
279
+ AliyunTrack.LoginLogout(logoutType);
280
280
 
281
281
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
282
282
  XDGEventBus.Publish(XDGEvents.TapSDKLogout);
283
- XDGEventBus.Publish(XDGEvents.TapSDKComplianceExit, ConfigModule.IsGlobal);
284
-
283
+ if (logoutType != "SWITCH_ACCOUNT" && logoutType != "COMPLIANCE_EXIT")
284
+ {
285
+ XDGEventBus.Publish(XDGEvents.TapSDKComplianceExit, ConfigModule.IsGlobal);
286
+ }
287
+
285
288
  ClearUserCache();
286
- // 确认协议
287
- _ = AgreementModule.ConfirmAgreement().ContinueWith(t =>
289
+
290
+ if (bShowAgreement)
288
291
  {
289
- if (!t.IsFaulted)
292
+ _ = AgreementModule.ConfirmAgreement().ContinueWith(t =>
290
293
  {
291
- if (needNotify)
294
+ if (!t.IsFaulted)
292
295
  {
293
- UserStatusChangeCallback?.Invoke(XDGUserStatusCodeType.ProtocolAgreedAfterLogout, null);
296
+ if (needNotify)
297
+ {
298
+ UserStatusChangeCallback?.Invoke(XDGUserStatusCodeType.ProtocolAgreedAfterLogout, null);
299
+ }
294
300
  }
295
- }
296
- }, TaskScheduler.FromCurrentSynchronizationContext());
301
+ }, TaskScheduler.FromCurrentSynchronizationContext());
302
+ }
297
303
 
298
304
  if (needNotify)
299
305
  {
@@ -384,6 +390,7 @@ namespace XD.SDK.Account.Internal.Standalone
384
390
  {
385
391
  XDGLogger.Warn($"[InvokeXdgPaymentCheckRefundStatusWithUI] Error:{e.Message}");
386
392
  }
393
+
387
394
  return user;
388
395
  }
389
396
 
@@ -0,0 +1,15 @@
1
+ namespace XD.SDK.Account.Standalone
2
+ {
3
+ public enum XDComplianceCode
4
+ {
5
+ LoginSuccess = 500,
6
+ Exited = 1000,
7
+ SwitchAccount = 1001,
8
+ PeriodRestrict = 1030,
9
+ DurationLimit = 1050,
10
+ AgeLimit = 1100,
11
+ InvalidClientOrNetworkError = 1200,
12
+ RealNameStop = 9002
13
+ }
14
+
15
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ccaddacb01aa48f4bcaca69420b1a6fb
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: a222155108264cc99220f4b5d789b3f0
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -19,7 +19,6 @@ namespace XD.SDK.Account.Internal.Standalone
19
19
 
20
20
  private SupportModule()
21
21
  {
22
- StartCheckUnRead();
23
22
  }
24
23
 
25
24
  public static SupportModule Instance
@@ -39,13 +38,24 @@ namespace XD.SDK.Account.Internal.Standalone
39
38
  }
40
39
  }
41
40
 
42
- public static readonly string XDG_SUPPORT_USER_UNREAD_CHECK = "api/support/v1/user/unread/check";
41
+ public void TryStartPolling()
42
+ {
43
+ if (!ConfigModule.CustomerDisable)
44
+ {
45
+ StartCheckUnRead();
46
+ return;
47
+ }
48
+
49
+ XDGLogger.Debug("XSupportManager is disabled by config, skipping polling start");
50
+ }
51
+
52
+ private const string XdgSupportUserUnreadCheck = "api/support/v1/user/unread/check";
43
53
 
44
- public static readonly string XDG_SUPPORT_ANONYMOUS_UNREAD_CHECK = "api/support/v1/user/anonymous/unread/check";
54
+ private const string XdgSupportAnonymousUnreadCheck = "api/support/v1/user/anonymous/unread/check";
45
55
 
46
- public static readonly string XDG_SUPPORT_USER_GET_URL = "api/support/v1/user/url/get";
56
+ private const string XdgSupportUserGetURL = "api/support/v1/user/url/get";
47
57
 
48
- public static readonly string XDG_SUPPORT_ANONYMOUS_GET_URL = "api/support/v1/user/anonymous/url/get";
58
+ private const string XdgSupportAnonymousGetURL = "api/support/v1/user/anonymous/url/get";
49
59
 
50
60
  private int nextCheckUnreadTime = 10;
51
61
 
@@ -84,13 +94,29 @@ namespace XD.SDK.Account.Internal.Standalone
84
94
  });
85
95
  }
86
96
 
87
- public static async void CheckUnRead()
97
+ private static async void CheckUnRead()
88
98
  {
89
99
  XDGLogger.Debug("Support check unread");
90
100
  try
91
101
  {
102
+ string requestUrl;
103
+ Dictionary<string, object> queryMap;
104
+ if (UserModule.GetCurrentUser() != null)
105
+ {
106
+ requestUrl = XdgSupportUserUnreadCheck;
107
+ queryMap = null;
108
+ }
109
+ else
110
+ {
111
+ requestUrl = XdgSupportAnonymousUnreadCheck;
112
+ queryMap = new Dictionary<string, object>()
113
+ {
114
+ { "anonymousId", SystemInfo.deviceUniqueIdentifier }
115
+ };
116
+ }
117
+
92
118
  var response = await XDHttpClient.Client.GetAsync<SupportBaseResponse<SupportUnReadResponse>>(
93
- UserModule.GetCurrentUser() != null ? XDG_SUPPORT_USER_UNREAD_CHECK : XDG_SUPPORT_ANONYMOUS_UNREAD_CHECK);
119
+ requestUrl,null, queryMap);
94
120
 
95
121
  var bHasUnRead = response.Data.HasUnread;
96
122
  var bUnReadStatusChange = bHasUnRead != Instance.bLastHasRead;
@@ -113,13 +139,13 @@ namespace XD.SDK.Account.Internal.Standalone
113
139
  StartCheckUnRead();
114
140
  }
115
141
 
116
- public static int IncreaseTimeInterval()
142
+ private static int IncreaseTimeInterval()
117
143
  {
118
144
  var currentInterval = Instance.nextCheckUnreadTime;
119
145
  return currentInterval >= 300 ? currentInterval : (currentInterval += 10);
120
146
  }
121
147
 
122
- public static void StartCheckUnRead()
148
+ private static void StartCheckUnRead()
123
149
  {
124
150
  try
125
151
  {
@@ -146,12 +172,13 @@ namespace XD.SDK.Account.Internal.Standalone
146
172
  XDGLogger.Warn($"Support Start CheckUnRead Action error:{e.Message}");
147
173
  }
148
174
  });
175
+ return;
149
176
  }
150
177
 
151
178
  CheckUnRead();
152
179
  }
153
180
 
154
- public static async void RequestSupportUrl(XDGRoleInfo roleInfo, string path, Dictionary<string, object> extra, Action<bool, bool, string> action)
181
+ private static async void RequestSupportUrl(XDGRoleInfo roleInfo, string path, Dictionary<string, object> extra, Action<bool, bool, string> action)
155
182
  {
156
183
  XDGLogger.Debug("Support RequestSupportUrl");
157
184
  try
@@ -160,6 +187,7 @@ namespace XD.SDK.Account.Internal.Standalone
160
187
  {
161
188
  path = "";
162
189
  }
190
+
163
191
  if (extra == null)
164
192
  {
165
193
  extra = new Dictionary<string, object>();
@@ -184,8 +212,8 @@ namespace XD.SDK.Account.Internal.Standalone
184
212
  };
185
213
 
186
214
  var response = await XDHttpClient.Client.PostAsync<SupportBaseResponse<SupportUrlResponse>>(UserModule.current == null
187
- ? XDG_SUPPORT_ANONYMOUS_GET_URL
188
- : XDG_SUPPORT_USER_GET_URL, null, data, UserModule.current == null ? query : null);
215
+ ? XdgSupportAnonymousGetURL
216
+ : XdgSupportUserGetURL, null, data, UserModule.current == null ? query : null);
189
217
 
190
218
  action.Invoke(true, response.Data.XD, response.Data.Url);
191
219
  }
@@ -303,7 +303,7 @@ namespace XD.SDK.Account.Standalone
303
303
  UIManager.ShowToast(localizableString.UnbindDeleteSuccessReturnSign);
304
304
  UIManager.DismissAll();
305
305
 
306
- AccountFeaturesImpl.InternalLogout();
306
+ AccountFeaturesImpl.Instance.InternalLogout();
307
307
  }
308
308
  else
309
309
  {
@@ -392,7 +392,7 @@ namespace XD.SDK.Account.Standalone
392
392
  if (code == 1)
393
393
  {
394
394
  UIManager.DismissAll();
395
- AccountFeaturesImpl.InternalLogout();
395
+ AccountFeaturesImpl.Instance.InternalLogout();
396
396
  }
397
397
  else
398
398
  {
@@ -15,6 +15,8 @@ namespace XD.SDK.Account
15
15
  XDGEventBus.Subscribe(XDGEvents.AccountGetCurrentUser, _ => XDGAccount.GetCurrentUser());
16
16
  #if UNITY_EDITOR || UNITY_STANDALONE
17
17
  XDGEventBus.SubscribeAsync(XDGEvents.AccountGetAccessToken, async _ => await AccessTokenModule.GetLocalAccessToken());
18
+
19
+ XDGEventBus.Subscribe(XDGEvents.AccountSupportStartPolling, _ => SupportModule.Instance.TryStartPolling());
18
20
  #endif
19
21
  }
20
22
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.xd.sdk.account",
3
3
  "displayName": "XDGSDK Account",
4
- "version": "0.0.10-alpha",
4
+ "version": "0.0.13-alpha",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.common": "0.0.10-alpha"
9
+ "com.xd.sdk.common": "0.0.13-alpha"
10
10
  }
11
11
  }