com.xd.sdk.account 7.6.3 → 7.7.3

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,6 +4,6 @@
4
4
  //
5
5
  // Created by Fattycat on 2023/4/14.
6
6
  //
7
- #define XDGAccount_VERSION @"7.6.3"
8
- #define XDSAccount_VERSION_CODE @"7060300"
9
- // HASH 3451ec11
7
+ #define XDGAccount_VERSION @"7.7.3"
8
+ #define XDSAccount_VERSION_CODE @"7070300"
9
+ // HASH 18c75b8c
@@ -8,6 +8,9 @@ using UnityEngine;
8
8
  using XD.SDK.Common;
9
9
  using XD.SDK.Common.Internal;
10
10
  using XD.SDK.Common.Internal.Standalone;
11
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
12
+ using XD.SDK.WebView;
13
+ #endif
11
14
 
12
15
 
13
16
  namespace XD.SDK.Account.Internal.Standalone
@@ -116,9 +119,10 @@ namespace XD.SDK.Account.Internal.Standalone
116
119
  if (xdException.Code == ResponseCode.Account.TokenExpired || xdException.HttpStatusCode == 401)
117
120
  errorMsg = "XD_TOKEN_EXPIRED";
118
121
  // 触发风控以及登陆频繁不需要发送 PreFail
119
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
120
- if (xdException.Code != PhoneModule.INVALID_VERIFY_CODE &&
121
- xdException.Code != PhoneModule.LOGIN_REQUEST_FREQUENTLY)
122
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
123
+ if (!XDWebViewService.IsAvailable ||
124
+ (xdException.Code != PhoneModule.INVALID_VERIFY_CODE &&
125
+ xdException.Code != PhoneModule.LOGIN_REQUEST_FREQUENTLY))
122
126
  {
123
127
  AliyunTrack.LoginPreFail(errorMsg);
124
128
  }
@@ -11,6 +11,9 @@ using XD.SDK.Common;
11
11
  using XD.SDK.Common.Internal;
12
12
  using XD.SDK.Common.Internal.Events;
13
13
  using XD.SDK.Common.Internal.Standalone;
14
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
15
+ using XD.SDK.WebView;
16
+ #endif
14
17
  using Random = System.Random;
15
18
 
16
19
  namespace XD.SDK.Account.Internal.Standalone
@@ -117,7 +120,7 @@ namespace XD.SDK.Account.Internal.Standalone
117
120
 
118
121
  public async void OpenUserDashboard(XDGRoleInfo roleInfo)
119
122
  {
120
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
123
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
121
124
  try
122
125
  {
123
126
  if (!XDGCommonInternal.IsCn())
@@ -134,6 +137,12 @@ namespace XD.SDK.Account.Internal.Standalone
134
137
  return;
135
138
  }
136
139
 
140
+ if (!XDWebViewService.IsAvailable)
141
+ {
142
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Account);
143
+ return;
144
+ }
145
+
137
146
  Dictionary<string, object> authData = new Dictionary<string, object>()
138
147
  { { "scope", UserModule.CodeScope.USER_INFO } };
139
148
  try
@@ -331,7 +340,7 @@ namespace XD.SDK.Account.Internal.Standalone
331
340
 
332
341
  private async Task CancelAccount()
333
342
  {
334
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
343
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
335
344
  var current = UserModule.current;
336
345
  if (current == null)
337
346
  {
@@ -347,6 +356,12 @@ namespace XD.SDK.Account.Internal.Standalone
347
356
  return;
348
357
  }
349
358
 
359
+ if (!XDWebViewService.IsAvailable)
360
+ {
361
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Account);
362
+ return;
363
+ }
364
+
350
365
  try
351
366
  {
352
367
  UIManager.ShowLoading();
@@ -22,11 +22,21 @@ namespace XD.SDK.Account.Internal.Standalone
22
22
  internal static string TryGetRedirectScheme()
23
23
  {
24
24
  #if UNITY_STANDALONE_WIN && !UNITY_EDITOR
25
- var scheme = StandaloneDeeplinkRegistrar.TryGetSchemeForCurrentGame();
26
- if (string.IsNullOrEmpty(scheme))
25
+ if (!StandaloneDeeplinkRegistrar.TryGetRegisteredScheme(out string scheme, out string reason))
27
26
  {
27
+ XDGLogger.Debug($"[DeepLink] RedirectScheme disabled. reason={reason}", XDGLoggerTag.Account);
28
28
  return null;
29
29
  }
30
+
31
+ if (!StandaloneDeepLinkReceiver.IsStarted)
32
+ {
33
+ XDGLogger.Debug(
34
+ $"[DeepLink] RedirectScheme disabled. reason=pipe receiver not started, {StandaloneDeeplinkRegistrar.GetRegistrationDiagnostic()}",
35
+ XDGLoggerTag.Account);
36
+ return null;
37
+ }
38
+
39
+ XDGLogger.Debug($"[DeepLink] RedirectScheme enabled. scheme={scheme}://", XDGLoggerTag.Account);
30
40
  return $"{scheme}://{DefaultUrlSchemePath}";
31
41
  #else
32
42
  return null;
@@ -72,7 +82,7 @@ namespace XD.SDK.Account.Internal.Standalone
72
82
  {
73
83
  if (string.IsNullOrEmpty(deepLinkUrl)) return;
74
84
 
75
- XDGLogger.Debug($"[Auth][DeepLink] url: {deepLinkUrl}", XDGLoggerTag.Account);
85
+ XDGLogger.Debug($"[Auth][DeepLink] url: {RedactAuthUrl(deepLinkUrl)}", XDGLoggerTag.Account);
76
86
 
77
87
  // 不用 new Uri(),直接截取 query,避免 Uri 对自定义 scheme 做编码归一化
78
88
  int qIdx = deepLinkUrl.IndexOf('?');
@@ -112,6 +122,7 @@ namespace XD.SDK.Account.Internal.Standalone
112
122
  {
113
123
  if (done == deepLinkTcs.Task)
114
124
  {
125
+ XDGLogger.Debug("[Auth] Callback channel: DeepLink", XDGLoggerTag.Account);
115
126
  XDGLogger.Debug("[Auth] DeepLink auth succeeded (won race)", XDGLoggerTag.Account);
116
127
  StopAllListeners();
117
128
  return await deepLinkTcs.Task;
@@ -119,6 +130,7 @@ namespace XD.SDK.Account.Internal.Standalone
119
130
 
120
131
  if (done == httpTask)
121
132
  {
133
+ XDGLogger.Debug("[Auth] Callback channel: HttpListener", XDGLoggerTag.Account);
122
134
  XDGLogger.Debug("[Auth] HTTP auth succeeded (won race)", XDGLoggerTag.Account);
123
135
  return await httpTask;
124
136
  }
@@ -144,6 +156,56 @@ namespace XD.SDK.Account.Internal.Standalone
144
156
  }
145
157
  }
146
158
  }
159
+
160
+ private static string RedactAuthUrl(string url)
161
+ {
162
+ if (string.IsNullOrEmpty(url))
163
+ {
164
+ return url;
165
+ }
166
+
167
+ int queryIndex = url.IndexOf('?');
168
+ if (queryIndex < 0 || queryIndex >= url.Length - 1)
169
+ {
170
+ return url;
171
+ }
172
+
173
+ string prefix = url.Substring(0, queryIndex + 1);
174
+ string query = url.Substring(queryIndex + 1);
175
+ string[] pairs = query.Split('&');
176
+ for (int i = 0; i < pairs.Length; i++)
177
+ {
178
+ string pair = pairs[i];
179
+ int equalIndex = pair.IndexOf('=');
180
+ if (equalIndex <= 0)
181
+ {
182
+ continue;
183
+ }
184
+
185
+ string key = pair.Substring(0, equalIndex);
186
+ if (IsSensitiveQueryKey(key))
187
+ {
188
+ pairs[i] = $"{key}=<redacted>";
189
+ }
190
+ }
191
+
192
+ return prefix + string.Join("&", pairs);
193
+ }
194
+
195
+ private static bool IsSensitiveQueryKey(string key)
196
+ {
197
+ if (string.IsNullOrEmpty(key))
198
+ {
199
+ return false;
200
+ }
201
+
202
+ return key.Equals("code", StringComparison.OrdinalIgnoreCase) ||
203
+ key.Equals("token", StringComparison.OrdinalIgnoreCase) ||
204
+ key.Equals("access_token", StringComparison.OrdinalIgnoreCase) ||
205
+ key.Equals("refresh_token", StringComparison.OrdinalIgnoreCase) ||
206
+ key.Equals("id_token", StringComparison.OrdinalIgnoreCase) ||
207
+ key.IndexOf("token", StringComparison.OrdinalIgnoreCase) >= 0;
208
+ }
147
209
  }
148
210
  }
149
- #endif
211
+ #endif
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -9,6 +9,9 @@ using UnityEngine;
9
9
  using XD.SDK.Common;
10
10
  using XD.SDK.Common.Internal;
11
11
  using XD.SDK.Common.Internal.Standalone;
12
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
13
+ using XD.SDK.WebView;
14
+ #endif
12
15
 
13
16
  namespace XD.SDK.Account.Internal.Standalone
14
17
  {
@@ -75,25 +78,32 @@ namespace XD.SDK.Account.Internal.Standalone
75
78
 
76
79
  if (xd)
77
80
  {
78
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
79
- WebRequest.OpenWebPage(url, (code, data) =>
81
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
82
+ if (XDWebViewService.IsAvailable)
80
83
  {
81
-
82
- });
83
- #else
84
- Application.OpenURL(url);
84
+ WebRequest.OpenWebPage(url, (code, data) =>
85
+ {
86
+ });
87
+ return;
88
+ }
89
+
90
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Support);
85
91
  #endif
86
92
  }
87
- else
88
- {
89
- Application.OpenURL(url);
90
- }
93
+
94
+ Application.OpenURL(url);
91
95
  });
92
96
  }
93
97
 
94
98
  private static async void CheckUnRead()
95
99
  {
96
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
100
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
101
+ if (!XDWebViewService.IsAvailable)
102
+ {
103
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Support);
104
+ return;
105
+ }
106
+
97
107
  XDGLogger.Debug("Support check unread", XDGLoggerTag.Support);
98
108
  try
99
109
  {
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using TMPro;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Linq;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using UnityEngine;
4
4
  using UnityEngine.UI;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Linq;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Threading.Tasks;
4
4
  using System.Collections.Generic;
@@ -7,7 +7,7 @@ using System.Net.Sockets;
7
7
  using Newtonsoft.Json;
8
8
  using UnityEngine;
9
9
  using UnityEngine.UI;
10
- using Vuplex.WebView;
10
+ using XD.SDK.WebView;
11
11
  using XD.SDK.Common;
12
12
  using XD.SDK.Common.Internal.Standalone;
13
13
 
@@ -18,11 +18,15 @@ namespace XD.SDK.Account.Internal.Standalone
18
18
  public const int CONTROL_DONE_CODE = 0;
19
19
  public const int CLOSE_CODE = -1;
20
20
  public const int BACK_CODE = 1;
21
+ private const float RequestLoadingTimeoutSeconds = 30f;
22
+ private const float WebLoadingTimeoutSeconds = 5f;
21
23
 
22
24
  private Button backButton;
23
25
  private Button closeButton;
24
26
 
25
- private CanvasWebViewPrefab canvasWebViewPrefab;
27
+ private IXDWebViewPanel webViewPanel;
28
+ private bool closeCallbackEmitted;
29
+ private bool controlRequestInProgress;
26
30
 
27
31
  public static async Task<int> Control(Func<string, Task<RequestVerifyCodeData>> requestVerifyCodeFunc)
28
32
  {
@@ -31,7 +35,7 @@ namespace XD.SDK.Account.Internal.Standalone
31
35
  TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();
32
36
  try
33
37
  {
34
- UIManager.ShowLoading(true);
38
+ UIManager.ShowLoading(true, RequestLoadingTimeoutSeconds);
35
39
  RequestVerifyCodeData verifyCodeData = await requestVerifyCodeFunc(riskControlData);
36
40
  tcs.TrySetResult(verifyCodeData.ReSendInterval);
37
41
  }
@@ -56,32 +60,54 @@ namespace XD.SDK.Account.Internal.Standalone
56
60
  riskControlData = data as string;
57
61
  try
58
62
  {
59
- UIManager.ShowLoading();
63
+ UIManager.ShowLoading(timeout: RequestLoadingTimeoutSeconds);
60
64
  RequestVerifyCodeData result = await requestVerifyCodeFunc(riskControlData);
65
+ if (!alert.TryClose())
66
+ {
67
+ return;
68
+ }
69
+
70
+ UIManager.Dismiss();
61
71
  tcs.TrySetResult(result.ReSendInterval);
62
72
  }
63
73
  catch (XDGError ex)
64
74
  {
75
+ if (alert.IsClosed)
76
+ {
77
+ return;
78
+ }
79
+
65
80
  UIManager.DismissLoading();
66
81
  if (ex.Code == PhoneModule.RISK_CONTROL)
67
82
  {
68
83
  // 触发风控
69
84
  await alert.Reload();
85
+ alert.ResetControlRequest();
70
86
  }
71
87
  else if (ex.Code == PhoneModule.RISK_CONTROL_FAILED)
72
88
  {
73
89
  // 滑动验证失败
74
90
  await alert.Reload();
91
+ alert.ResetControlRequest();
75
92
  UIManager.ShowToast(ex.ErrorMsg);
76
93
  }
77
94
  else
78
95
  {
96
+ if (!alert.TryClose())
97
+ {
98
+ return;
99
+ }
100
+
101
+ UIManager.Dismiss();
79
102
  tcs.TrySetException(ex);
80
103
  }
81
104
  }
82
105
  finally
83
106
  {
84
- UIManager.DismissLoading();
107
+ if (!alert.IsClosed)
108
+ {
109
+ UIManager.DismissLoading();
110
+ }
85
111
  }
86
112
  }
87
113
  });
@@ -106,9 +132,9 @@ namespace XD.SDK.Account.Internal.Standalone
106
132
  private void Awake()
107
133
  {
108
134
  Transform webviewContainer = transform.Find("WebViewContainer");
109
- canvasWebViewPrefab = CanvasWebViewPrefab.Instantiate();
110
- canvasWebViewPrefab.transform.SetParent(webviewContainer);
111
- RectTransform rectTransform = canvasWebViewPrefab.GetComponent<RectTransform>();
135
+ webViewPanel = XDWebViewService.Provider.CreatePanel();
136
+ webViewPanel.GameObject.transform.SetParent(webviewContainer);
137
+ RectTransform rectTransform = webViewPanel.GameObject.GetComponent<RectTransform>();
112
138
  rectTransform.offsetMin = Vector2.zero;
113
139
  rectTransform.offsetMax = Vector2.zero;
114
140
 
@@ -121,20 +147,19 @@ namespace XD.SDK.Account.Internal.Standalone
121
147
 
122
148
  private async void Start()
123
149
  {
124
- UIManager.ShowLoading();
150
+ UIManager.ShowLoading(timeout: WebLoadingTimeoutSeconds);
125
151
 
126
- await canvasWebViewPrefab.WaitUntilInitialized();
152
+ await webViewPanel.WaitUntilInitialized();
127
153
 
128
- canvasWebViewPrefab.DragMode = DragMode.DragWithinPage;
154
+ webViewPanel.DragMode = XDWebViewDragMode.DragWithinPage;
129
155
 
130
- canvasWebViewPrefab.WebView.MessageEmitted += (sender, eventArgs) =>
156
+ webViewPanel.WebView.MessageEmitted += (sender, message) =>
131
157
  {
132
- XDGLogger.Debug(eventArgs.Value, XDGLoggerTag.Web);
133
- Dictionary<string, string> response = JsonConvert.DeserializeObject<Dictionary<string, string>>(eventArgs.Value);
158
+ XDGLogger.Debug(message, XDGLoggerTag.Web);
159
+ Dictionary<string, string> response = JsonConvert.DeserializeObject<Dictionary<string, string>>(message);
134
160
  Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(response["message"]);
135
161
  string riskControlData = JsonConvert.SerializeObject(data["data"]);
136
162
  XDGLogger.Debug(riskControlData, XDGLoggerTag.Web);
137
- UIManager.Dismiss();
138
163
 
139
164
  OnCallback(CONTROL_DONE_CODE, riskControlData);
140
165
  };
@@ -172,25 +197,30 @@ namespace XD.SDK.Account.Internal.Standalone
172
197
 
173
198
  private async Task Reload()
174
199
  {
175
- UIManager.ShowLoading();
200
+ UIManager.ShowLoading(timeout: WebLoadingTimeoutSeconds);
176
201
  var ip = GetIP();
177
- canvasWebViewPrefab.WebView.LoadUrl(
202
+ webViewPanel.WebView.LoadUrl(
178
203
  $"https://login-xdsdk.xd.cn/awsc?platform={Platform}&eventSessionId={AliyunTrack.LoginEventSessionId}&login_type=Phone&sub_login_type=2&xd_client_id={ConfigModule.ClientId}&device_id={SystemInfo.deviceUniqueIdentifier}&os={SystemInfo.operatingSystem}&ip={ip}&app_version={Application.version}&language={XDLocalization.CurrentLang.ToString()}");
179
- await canvasWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
180
- // 注入 js
181
- _ = canvasWebViewPrefab.WebView.ExecuteJavaScript(@";(function (window) {
204
+ try
205
+ {
206
+ await webViewPanel.WebView.WaitForNextPageLoadToFinish();
207
+ // 注入 js
208
+ _ = webViewPanel.WebView.ExecuteJavaScript(@";(function (window) {
182
209
  window._xd_jsbridge = {
183
210
  invoke: function (json) {
184
211
  try {
185
- window.vuplex.postMessage({ type: 'verify', message: json });
212
+ " + XDWebViewService.Provider.JsPostMessageFunction + @"({ type: 'verify', message: json });
186
213
  } catch (error) {
187
214
  console.error('xd-jsbridge error::', error)
188
215
  }
189
216
  },
190
217
  };
191
218
  })(window);");
192
-
193
- UIManager.DismissLoading();
219
+ }
220
+ finally
221
+ {
222
+ UIManager.DismissLoading();
223
+ }
194
224
  }
195
225
 
196
226
  private string Platform
@@ -224,7 +254,49 @@ namespace XD.SDK.Account.Internal.Standalone
224
254
  OnCallback(CLOSE_CODE, null);
225
255
  }
226
256
 
257
+ protected override void OnCallback(int code, object data)
258
+ {
259
+ if (code == CLOSE_CODE || code == BACK_CODE)
260
+ {
261
+ if (!TryClose())
262
+ {
263
+ return;
264
+ }
265
+ }
266
+ else if (code == CONTROL_DONE_CODE)
267
+ {
268
+ if (closeCallbackEmitted || controlRequestInProgress)
269
+ {
270
+ return;
271
+ }
272
+
273
+ controlRequestInProgress = true;
274
+ UIManager.DismissLoading();
275
+ }
276
+
277
+ base.OnCallback(code, data);
278
+ }
279
+
280
+ private void ResetControlRequest()
281
+ {
282
+ controlRequestInProgress = false;
283
+ }
284
+
285
+ private bool TryClose()
286
+ {
287
+ if (closeCallbackEmitted)
288
+ {
289
+ return false;
290
+ }
291
+
292
+ closeCallbackEmitted = true;
293
+ UIManager.DismissLoading();
294
+ return true;
295
+ }
296
+
297
+ private bool IsClosed => closeCallbackEmitted;
298
+
227
299
  #endregion
228
300
  }
229
301
  }
230
- #endif
302
+ #endif
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Threading.Tasks;
4
4
  using System.Collections;
@@ -9,11 +9,27 @@ using XD.SDK.Common;
9
9
  using XD.SDK.Common.Internal;
10
10
  using XD.SDK.Common.Internal.Events;
11
11
  using XD.SDK.Common.Internal.Standalone;
12
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
13
+ using XD.SDK.WebView;
14
+ #endif
12
15
 
13
16
  namespace XD.SDK.Account.Internal.Standalone
14
17
  {
15
18
  public class UserModule
16
19
  {
20
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
21
+ private static void EnsureWebViewAvailable()
22
+ {
23
+ if (XDWebViewService.IsAvailable)
24
+ {
25
+ return;
26
+ }
27
+
28
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Account);
29
+ throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
30
+ }
31
+ #endif
32
+
17
33
  public class CodeScope
18
34
  {
19
35
  // Code Scope 个人信息页
@@ -108,7 +124,8 @@ namespace XD.SDK.Account.Internal.Standalone
108
124
  if (loginType == LoginType.Phone)
109
125
  {
110
126
  AliyunTrack.ResetPhoneLoginData();
111
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
127
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
128
+ EnsureWebViewAvailable();
112
129
  if (XDGCommonInternal.IsCn())
113
130
  {
114
131
  await PhoneModule.Bind();
@@ -120,7 +137,6 @@ namespace XD.SDK.Account.Internal.Standalone
120
137
  #else
121
138
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
122
139
  #endif
123
-
124
140
  return;
125
141
  }
126
142
  else if (loginType == LoginType.Email)
@@ -132,7 +148,8 @@ namespace XD.SDK.Account.Internal.Standalone
132
148
  }
133
149
  else
134
150
  {
135
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
151
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
152
+ EnsureWebViewAvailable();
136
153
  await EmailModule.LoginOrBind(false);
137
154
  #else
138
155
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
@@ -151,7 +168,8 @@ namespace XD.SDK.Account.Internal.Standalone
151
168
  if (loginType == LoginType.Phone)
152
169
  {
153
170
  AliyunTrack.ResetPhoneLoginData();
154
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
171
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
172
+ EnsureWebViewAvailable();
155
173
  // 手机号解绑需要验证码
156
174
  if (XDGCommonInternal.IsCn())
157
175
  {
@@ -174,7 +192,8 @@ namespace XD.SDK.Account.Internal.Standalone
174
192
  }
175
193
  else
176
194
  {
177
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
195
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
196
+ EnsureWebViewAvailable();
178
197
  return EmailModule.Unbind(extras);
179
198
  #else
180
199
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
@@ -265,7 +284,8 @@ namespace XD.SDK.Account.Internal.Standalone
265
284
  {
266
285
  AliyunTrack.ResetPhoneLoginData();
267
286
  AliyunTrack.LoginEnableSDKLoginTrack();
268
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
287
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
288
+ EnsureWebViewAvailable();
269
289
  if (XDGCommonInternal.IsCn())
270
290
  {
271
291
  await PhoneModule.Login();
@@ -284,13 +304,13 @@ namespace XD.SDK.Account.Internal.Standalone
284
304
  {
285
305
  AliyunTrack.ResetEmailLoginData();
286
306
  AliyunTrack.LoginEnableSDKLoginTrack();
287
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
307
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
308
+ EnsureWebViewAvailable();
288
309
  await EmailModule.LoginOrBind(true);
289
310
  UIManager.ShowLoading();
290
311
  #else
291
312
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
292
313
  #endif
293
-
294
314
  }
295
315
  else
296
316
  {
@@ -4,7 +4,7 @@
4
4
  "references": [
5
5
  "XD.SDK.Common",
6
6
  "XD.SDK.Foundation",
7
- "Vuplex.WebView",
7
+ "XD.SDK.WebView",
8
8
  "Unity.TextMeshPro",
9
9
  "TapTap.Common.Runtime",
10
10
  "TapTap.Login.Runtime"
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.xd.sdk.account",
3
3
  "displayName": "XDGSDK Account",
4
- "version": "7.6.3",
4
+ "version": "7.7.3",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.common": "7.6.3"
9
+ "com.xd.sdk.common": "7.7.3"
10
10
  }
11
11
  }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 2e63b267153141939359668e82217cb0
3
- timeCreated: 1752580026