com.xd.sdk.common 7.0.2 → 7.1.1

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.
Files changed (41) hide show
  1. package/Editor/Android/XDCommonAndroidGradleProcessor.cs +1 -3
  2. package/Editor/iOS/XDGIOSCommonProcessor.cs +1 -1
  3. package/Plugins/Android/libs/XDGCommon_7.1.0.aar +0 -0
  4. package/Plugins/Android/libs/XDGTapTapWrapperInternal_7.1.0.aar +0 -0
  5. package/Plugins/iOS/XDCommonSDK.framework/Headers/NSDictionary+XDG.h +1 -0
  6. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDCommonSDK.h +2 -0
  7. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDFacebookInfo.h +2 -0
  8. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGAnnouncementConfig.h +26 -0
  9. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGAnnouncementManager.h +28 -0
  10. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGBridgeWeb.h +5 -3
  11. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGConfig.h +2 -2
  12. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGLogger.h +2 -0
  13. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGWebParams.h +2 -1
  14. package/Plugins/iOS/XDCommonSDK.framework/Headers/XDVersion.h +3 -3
  15. package/Plugins/iOS/XDCommonSDK.framework/Info.plist +0 -0
  16. package/Plugins/iOS/XDCommonSDK.framework/XDCommonSDK +0 -0
  17. package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Headers/XDTapSDK4WrapperSDK.h +3 -3
  18. package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/Info.plist +0 -0
  19. package/Plugins/iOS/XDTapSDK4WrapperSDK.framework/XDTapSDK4WrapperSDK +0 -0
  20. package/Resources/Prefabs/XDSDKUI.prefab +1 -1
  21. package/Runtime/Internal/Mobile/Bridge/BridgeConstants.cs +7 -0
  22. package/Runtime/Internal/Mobile/CommonFeaturesImpl.cs +1 -0
  23. package/Runtime/Internal/Standalone/CommonFeaturesImpl.cs +8 -3
  24. package/Runtime/Internal/Standalone/Config/AppConfig.cs +3 -1
  25. package/Runtime/Internal/Standalone/Config/Config.cs +3 -1
  26. package/Runtime/Internal/Standalone/Config/ConfigModule.cs +5 -1
  27. package/Runtime/Internal/Standalone/Utils/SteamWrapper.cs +77 -32
  28. package/Runtime/Internal/Standalone/Web/Function/CloseVisibleWebFunction.cs +0 -1
  29. package/Runtime/Internal/Standalone/Web/PreloadWebTransmit.cs +1 -0
  30. package/Runtime/Internal/Standalone/Web/PreloadWebTransmit.cs.meta +3 -0
  31. package/Runtime/Internal/Standalone/Web/WebRequest.cs +62 -13
  32. package/Runtime/Internal/Standalone/Web/XDWebBridgeView.cs +8 -34
  33. package/package.json +2 -2
  34. package/Plugins/Android/libs/XDGCommon_7.0.1.aar +0 -0
  35. package/Plugins/Android/libs/XDGTapTapWrapperInternal_7.0.1.aar +0 -0
  36. /package/Plugins/Android/libs/{XDGBridgeCommon_v7_7.0.1.aar → XDGBridgeCommon_v7_7.1.0.aar} +0 -0
  37. /package/Plugins/Android/libs/{XDGBridgeCommon_v7_7.0.1.aar.meta → XDGBridgeCommon_v7_7.1.0.aar.meta} +0 -0
  38. /package/Plugins/Android/libs/{XDGCommon_7.0.1.aar.meta → XDGCommon_7.1.0.aar.meta} +0 -0
  39. /package/Plugins/Android/libs/{XDGTapTapWrapperInternal_7.0.1.aar.meta → XDGTapTapWrapperInternal_7.1.0.aar.meta} +0 -0
  40. /package/Plugins/Android/libs/{XDTapTapWrapper_7.0.1.aar → XDTapTapWrapper_7.1.0.aar} +0 -0
  41. /package/Plugins/Android/libs/{XDTapTapWrapper_7.0.1.aar.meta → XDTapTapWrapper_7.1.0.aar.meta} +0 -0
@@ -1,4 +1,3 @@
1
- #if UNITY_EDITOR && UNITY_ANDROID
2
1
  using System.Collections.Generic;
3
2
  using System.IO;
4
3
  using UnityEditor.Build;
@@ -108,5 +107,4 @@ namespace XD.SDK.Common.Editor
108
107
  if (File.Exists(targetPath)) File.Delete(targetPath);
109
108
  }
110
109
  }
111
- }
112
- #endif
110
+ }
@@ -251,7 +251,7 @@ namespace XD.SDK.Common.Editor
251
251
  }
252
252
  else
253
253
  {
254
- Debug.LogError("[XDSDK] 资源文件夹不存在: " + moduleIOSResourcesFolder);
254
+ Debug.LogWarning("[XDSDK] 资源文件夹不存在: " + moduleIOSResourcesFolder);
255
255
  }
256
256
  }
257
257
 
@@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
24
24
  - (NSString *)xdg_jsonStringNotPretty;
25
25
  - (NSString *)xdg_jsonStringPretty;
26
26
  - (NSDictionary *)safeDictionary;
27
+ - (NSString *)xdg_queryString;
27
28
  @end
28
29
 
29
30
  NS_ASSUME_NONNULL_END
@@ -114,3 +114,5 @@ FOUNDATION_EXPORT const unsigned char XDCommonSDKVersionString[];
114
114
  #import <XDCommonSDK/XDGWebFunctionHolder.h>
115
115
 
116
116
  #import <XDCommonSDK/XDGTapSDK.h>
117
+ #import <XDCommonSDK/XDGAnnouncementManager.h>
118
+ #import <XDCommonSDK/XDGAnnouncementConfig.h>
@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
13
13
 
14
14
  @property (nonatomic, copy) NSString *appId;
15
15
  @property (nonatomic, copy) NSString *clientToken;
16
+ @property (nonatomic, copy) NSString *gameName;
17
+ @property (nonatomic, strong) NSArray *loginPermissions;
16
18
 
17
19
  + (instancetype)instanceWithInfoDic:(NSDictionary *)infoDic;
18
20
  @end
@@ -0,0 +1,26 @@
1
+ //
2
+ // XDGAnnouncementConfig.h
3
+ // XDCommonSDK
4
+ //
5
+ // Created by Fattycat on 2025/10/20.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface XDGAnnouncementConfig : NSObject
13
+
14
+ /// 服务器 Code
15
+ @property (nonatomic, strong, nullable) NSString *serverCode;
16
+ /// 渠道标签
17
+ @property (nonatomic, strong, nullable) NSString *channel;
18
+ /// 透传参数
19
+ @property (nonatomic, strong, nullable) NSString *extra;
20
+
21
+ + (instancetype)configWithDict:(NSDictionary *)dict;
22
+
23
+ - (NSDictionary *)toDictionary;
24
+ @end
25
+
26
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
1
+ //
2
+ // XDGAnnouncementManager.h
3
+ // XDCommonSDK
4
+ //
5
+ // Created by Fattycat on 2025/10/14.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ #import <XDCommonSDK/XDGWebDefines.h>
11
+ #import <XDCommonSDK/XDGAnnouncementConfig.h>
12
+
13
+ NS_ASSUME_NONNULL_BEGIN
14
+
15
+ @interface XDGAnnouncementManager : NSObject
16
+
17
+ /// 打开公告页面
18
+ /// - Parameters:
19
+ /// - data: 数据
20
+ /// - handler: 回调
21
+ + (void)openPageWithConfig:(XDGAnnouncementConfig *)config handler:(XDGWebActionHandler _Nullable)handler;
22
+
23
+ /// 获取公告未读状态
24
+ /// - Parameter handler: 回调
25
+ + (void)requestUnreadWithConfig:(XDGAnnouncementConfig *)config handler:(void (^)(bool hasRedDot))handler;
26
+ @end
27
+
28
+ NS_ASSUME_NONNULL_END
@@ -15,11 +15,11 @@ NS_ASSUME_NONNULL_BEGIN
15
15
 
16
16
  @property (nonatomic, strong, readonly) WKWebView *webView;
17
17
 
18
- @property (nonatomic, weak) UIViewController *rootViewController;
18
+ @property (nonatomic, weak, nullable) UIViewController *rootViewController;
19
19
 
20
- @property (nonatomic, weak) id<XDGBridgeIWebController> controller;
20
+ @property (nonatomic, weak, nullable) id<XDGBridgeIWebController> controller;
21
21
 
22
- @property (nonatomic, copy) XDGWebActionHandler webHandler;
22
+ @property (nonatomic, copy, nullable) XDGWebActionHandler webHandler;
23
23
 
24
24
  - (instancetype)initWithDefault:(BOOL)isPreload;
25
25
 
@@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
29
29
 
30
30
  - (void)dismiss;
31
31
 
32
+ - (void)dismissWithData:(NSDictionary *_Nullable)data;
33
+
32
34
  @end
33
35
 
34
36
  NS_ASSUME_NONNULL_END
@@ -53,8 +53,6 @@ typedef NS_ENUM(NSInteger, XDSDKRegionType) {
53
53
  @property (nonatomic, strong) XDAppleInfo *appleInfo;
54
54
  /// Facebook 配置信息
55
55
  @property (nonatomic, strong) XDFacebookInfo *facebookInfo;
56
- /// Facebook 授权权限,如果使用 Facebook 登录,必须配置
57
- @property (nonatomic, strong) NSArray *facebookLoginPersmissions;
58
56
  /// TikTok 配置信息
59
57
  @property (nonatomic, strong) XDTikTokInfo *tiktokInfo;
60
58
  /// Line 配置信息
@@ -110,6 +108,8 @@ typedef NS_ENUM(NSInteger, XDSDKRegionType) {
110
108
  @property (nonatomic, assign) BOOL pushAutoInit;
111
109
  /// 关闭客服
112
110
  @property (nonatomic, assign) BOOL disableSupport;
111
+ /// 关闭网页预热
112
+ @property (nonatomic, assign) BOOL disableWebPreload;
113
113
 
114
114
  - (BOOL)isCN;
115
115
 
@@ -23,6 +23,8 @@ typedef void (^XDGLoggerCallback) (NSString *content);
23
23
 
24
24
  + (void)commonSecureLog:(NSString *)content;
25
25
 
26
+ + (void)commonLog:(NSString *)content secureContent:(NSString *_Nullable)secureContent;
27
+
26
28
  + (void)logWithTag:(NSString *)tag content:(NSString *)content;
27
29
 
28
30
  + (void)logSecureWithTag:(NSString *)tag content:(NSString *)content;
@@ -17,10 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
17
17
  @property (nonatomic, strong, nullable) NSString *targetUrl;
18
18
  @property (nonatomic, strong, nullable) NSString *backgroundColor;
19
19
  @property (nonatomic, strong, nullable) NSString *navigationTitle;
20
+ @property (nonatomic, copy, nullable) XDGWebActionHandler webHandler;
20
21
  @property (nonatomic, assign) BOOL showNavigationBar;
21
22
  @property (nonatomic, assign) BOOL showCloseButton;
22
23
  @property (nonatomic, assign) BOOL showLoading;
23
- @property (nonatomic, copy) XDGWebActionHandler webHandler;
24
+ @property (nonatomic, assign) BOOL noUI;
24
25
 
25
26
  + (XDGWebParams *)paramsWithUrl:(NSString *)url;
26
27
 
@@ -5,6 +5,6 @@
5
5
  // Created by Fattycat on 2022/5/13.
6
6
  //
7
7
 
8
- #define XDSDK_VERSION @"7.0.2"
9
- #define XDSDK_VERSION_CODE @"7000020"
10
- // HASH ed74f1fb
8
+ #define XDSDK_VERSION @"7.1.0"
9
+ #define XDSDK_VERSION_CODE @"7001000"
10
+ // HASH 669fedcf
@@ -15,6 +15,6 @@ FOUNDATION_EXPORT const unsigned char XDTapSDK4WrapperSDKVersionString[];
15
15
 
16
16
  // In this header, you should import all the public headers of your framework using statements like #import <XDTapSDK4WrapperSDK/PublicHeader.h>
17
17
 
18
- #define XDGTapSDK4_VERSION @"7.0.2"
19
- #define XDGTapSDK4_VERSION_CODE @"7000020"
20
- // HASH ed74f1fb
18
+ #define XDGTapSDK4_VERSION @"7.1.0"
19
+ #define XDGTapSDK4_VERSION_CODE @"7001000"
20
+ // HASH 669fedcf
@@ -138,7 +138,7 @@ Canvas:
138
138
  m_AdditionalShaderChannelsFlag: 0
139
139
  m_UpdateRectTransformForStandalone: 0
140
140
  m_SortingLayerID: 0
141
- m_SortingOrder: 999
141
+ m_SortingOrder: 1001
142
142
  m_TargetDisplay: 0
143
143
  --- !u!114 &114453665955884244
144
144
  MonoBehaviour:
@@ -46,6 +46,13 @@ namespace XD.SDK.Common.Internal.Mobile.Bridge
46
46
  public const string ServiceImpl = "com.xd.sdk.push.bridge.BridgePushImpl";
47
47
  }
48
48
 
49
+ public static class Announcement
50
+ {
51
+ public const string BridgeName = "XDGBridgeAnnouncement";
52
+ public const string ServiceName = "com.xd.sdk.announcement.bridge.BridgeAnnouncement";
53
+ public const string ServiceImpl = "com.xd.sdk.announcement.bridge.BridgeAnnouncementImpl";
54
+ }
55
+
49
56
  }
50
57
  }
51
58
  #endif
@@ -14,6 +14,7 @@ namespace XD.SDK.Common.Internal.Mobile
14
14
  public class CommonFeaturesImpl : IXDGCommonExtended
15
15
  {
16
16
  private static CommonFeaturesImpl instance;
17
+
17
18
  private static readonly object lockObj = new object();
18
19
 
19
20
  public static CommonFeaturesImpl Instance
@@ -191,7 +191,7 @@ namespace XD.SDK.Common.Internal.Standalone
191
191
  //TODO 初始化客服
192
192
  InitSupportModule();
193
193
  // TODO UA 设置因为 WebView Demo 得提前设置,所有后续需要改造
194
- InitWebViewUa();
194
+ InitWebView();
195
195
 
196
196
  isInited = true;
197
197
  }
@@ -229,15 +229,20 @@ namespace XD.SDK.Common.Internal.Standalone
229
229
  XDGEventBus.Publish(XDGEvents.AccountSupportStartPolling);
230
230
  }
231
231
 
232
- private static void InitWebViewUa()
232
+ private static void InitWebView()
233
233
  {
234
234
  var region = ConfigModule.IsGlobal ? "global" : "cn";
235
235
  try
236
236
  {
237
237
  Web.SetUserAgent($"{WebBridgeConstants.UserAgent} Unity/{Application.unityVersion} XDSDK/{XDGConstants.SDK_VERSION} ({XDGConstants.SDK_VERSION_CODE}; {region})");
238
238
  }
239
- catch (Exception e)
239
+ catch (Exception)
240
+ {
241
+ // ignore
242
+ }
243
+ if (!ConfigModule.DisableWebPreload)
240
244
  {
245
+ WebRequest.Preload(ConfigModule.IsGlobal ? "https://poster.xd.com/r/versions.html" : "https://poster.xd.cn/r/versions.html");
241
246
  }
242
247
  }
243
248
  }
@@ -42,7 +42,7 @@ namespace XD.SDK.Common.Internal.Standalone
42
42
  [JsonProperty("anit")] public AntiConfig Anti { get; internal set; }
43
43
 
44
44
  [JsonProperty("customer_disable")] public bool CustomerDisable { get; internal set; }
45
-
45
+
46
46
  [JsonIgnore] public string Region { get; internal set; }
47
47
 
48
48
  [JsonIgnore] public List<BindEntryConfig> BindEntryConfigs { get; internal set; }
@@ -53,6 +53,7 @@ namespace XD.SDK.Common.Internal.Standalone
53
53
 
54
54
  [JsonIgnore] public bool DisableAutoLogin2Tap { get; set; }
55
55
 
56
+ [JsonIgnore] public bool DisableWebPreload { get; set; }
56
57
 
57
58
  /// <summary>
58
59
  /// 判断是否为海外
@@ -63,6 +64,7 @@ namespace XD.SDK.Common.Internal.Standalone
63
64
  {
64
65
  #if UNITY_STANDALONE_WIN
65
66
  // win 环境 + packageType 为 tapPC + clientPublicKey 不为空
67
+ XDGLogger.Debug($"UsingTapPC:{IsGlobal} pacakgeType:{PackageType} TapConfig:{TapConfig != null} !clientPublicKey:{!string.IsNullOrEmpty(TapConfig?.ClientPublicKey)}");
66
68
  return !IsGlobal && string.Equals(PackageType, XDGPackageType.PackageTypePCTapTap) && TapConfig != null && !string.IsNullOrEmpty(TapConfig.ClientPublicKey);
67
69
  #endif
68
70
  return false;
@@ -22,8 +22,10 @@ namespace XD.SDK.Common.Internal.Standalone
22
22
  [JsonProperty("webWhiteList")] public List<string> WebWhiteList { get; private set; }
23
23
 
24
24
  [JsonProperty("disableAutoLogin2Tap")] public bool DisableAutoLogin2Tap { get; private set; }
25
-
25
+
26
26
  [JsonProperty("anti")] public AntiConfig Anti { get; private set; }
27
+
28
+ [JsonProperty("disableWebPreload")] public bool DisableWebPreload { get; private set; }
27
29
  }
28
30
  }
29
31
  #endif
@@ -35,7 +35,7 @@ namespace XD.SDK.Common.Internal.Standalone
35
35
  private static string LoadConfigText()
36
36
  {
37
37
  #if UNITY_EDITOR
38
- var xdConfigFilePath = GetXDConfigPath(ConfigFile);
38
+ var xdConfigFilePath = GetXDConfigPath(ConfigFile);
39
39
  #else
40
40
  var xdConfigFilePath = Path.Combine(Application.streamingAssetsPath, $"{ConfigFile}.json");
41
41
  #endif
@@ -199,6 +199,8 @@ namespace XD.SDK.Common.Internal.Standalone
199
199
  }
200
200
  }
201
201
 
202
+ _appConfig.DisableWebPreload = config.DisableWebPreload;
203
+
202
204
  _appConfig.DisableAutoLogin2Tap = config.DisableAutoLogin2Tap;
203
205
  }
204
206
 
@@ -249,6 +251,8 @@ namespace XD.SDK.Common.Internal.Standalone
249
251
  public static string CancelUrl => _appConfig.CancelUrl;
250
252
 
251
253
  public static bool CustomerDisable => _appConfig.CustomerDisable;
254
+
255
+ public static bool DisableWebPreload => _appConfig.DisableWebPreload;
252
256
  }
253
257
  }
254
258
  #endif
@@ -2,60 +2,93 @@
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Collections.Concurrent;
5
+ using System.Linq;
6
+ using System.Reflection;
5
7
  using System.Threading.Tasks;
6
8
  using Steamworks;
7
9
  using Newtonsoft.Json;
8
10
 
9
- namespace XD.SDK.Common.Internal.Standalone {
10
- public class SteamWrapper : ISteamSDKWrapper {
11
+ namespace XD.SDK.Common.Internal.Standalone
12
+ {
13
+ public class SteamWrapper : ISteamSDKWrapper
14
+ {
11
15
  private readonly Callback<GetAuthSessionTicketResponse_t> getAuthSessionTicketResponseCallback;
12
16
  private readonly ConcurrentDictionary<HAuthTicket, Tuple<TaskCompletionSource<string>, string>> tickTasks;
13
17
 
14
18
  private readonly Callback<MicroTxnAuthorizationResponse_t> mircoTxnAuthorizationCallback;
15
19
  private readonly ConcurrentDictionary<ulong, TaskCompletionSource<string>> microTxnTasks;
20
+ private readonly Type _steamManagerType;
16
21
 
17
- public SteamWrapper() {
22
+ public SteamWrapper()
23
+ {
18
24
  tickTasks = new ConcurrentDictionary<HAuthTicket, Tuple<TaskCompletionSource<string>, string>>();
19
25
 
20
- getAuthSessionTicketResponseCallback = Callback<GetAuthSessionTicketResponse_t>.Create((GetAuthSessionTicketResponse_t pCallback) => {
26
+ getAuthSessionTicketResponseCallback = Callback<GetAuthSessionTicketResponse_t>.Create((GetAuthSessionTicketResponse_t pCallback) =>
27
+ {
21
28
  HAuthTicket authTicket = pCallback.m_hAuthTicket;
22
- if (tickTasks.TryRemove(authTicket, out Tuple<TaskCompletionSource<string>, string> callback)) {
29
+ if (tickTasks.TryRemove(authTicket, out Tuple<TaskCompletionSource<string>, string> callback))
30
+ {
23
31
  callback.Item1.TrySetResult(callback.Item2);
24
32
  }
25
33
  });
26
34
 
27
35
  microTxnTasks = new ConcurrentDictionary<ulong, TaskCompletionSource<string>>();
28
36
 
29
- mircoTxnAuthorizationCallback = Callback<MicroTxnAuthorizationResponse_t>.Create((MicroTxnAuthorizationResponse_t pCallback) => {
37
+ mircoTxnAuthorizationCallback = Callback<MicroTxnAuthorizationResponse_t>.Create((MicroTxnAuthorizationResponse_t pCallback) =>
38
+ {
30
39
  // 根据 pCallback.m_ulOrderID 查找对应的回调
31
40
  ulong orderId = pCallback.m_ulOrderID;
32
41
  UnityEngine.Debug.Log($"recv order id: {orderId}");
33
- if (microTxnTasks.TryGetValue(orderId, out TaskCompletionSource<string> tcs)) {
34
- if (pCallback.m_bAuthorized == 1) {
35
- Dictionary<string, object> data = new Dictionary<string, object> {
42
+ if (microTxnTasks.TryGetValue(orderId, out TaskCompletionSource<string> tcs))
43
+ {
44
+ if (pCallback.m_bAuthorized == 1)
45
+ {
46
+ Dictionary<string, object> data = new Dictionary<string, object>
47
+ {
36
48
  { "appId", pCallback.m_unAppID },
37
49
  { "orderId", pCallback.m_ulOrderID },
38
50
  { "authorized", pCallback.m_bAuthorized }
39
51
  };
40
52
  tcs.TrySetResult(JsonConvert.SerializeObject(data));
41
- } else {
53
+ }
54
+ else
55
+ {
42
56
  tcs.TrySetException(new XDGError(ResponseCode.Common.Failed, "Steam authorization failure"));
43
57
  }
44
58
  }
45
59
  });
60
+
61
+ _steamManagerType = AppDomain.CurrentDomain.GetAssemblies()
62
+ .SelectMany(a => a.GetTypes())
63
+ .FirstOrDefault(t => t.Name == "SteamManager");
64
+ }
65
+
66
+ private bool Initialized()
67
+ {
68
+ var initialized = false;
69
+ if (_steamManagerType == null) return false;
70
+ var prop = _steamManagerType.GetProperty("Initialized", BindingFlags.Public | BindingFlags.Static);
71
+ if (prop != null)
72
+ {
73
+ initialized = (bool)prop.GetValue(null);
74
+ }
75
+ return initialized;
46
76
  }
77
+
78
+ public Task<string> GetAuthTicket()
79
+ {
80
+ if (!Initialized())
81
+ {
82
+ throw new Exception("Steam did not initialize.");
83
+ }
47
84
 
48
- public Task<string> GetAuthTicket() {
49
- // if (!SteamManager.Initialized) {
50
- // throw new Exception("Steam did not initialize.");
51
- // }
52
85
 
53
86
  TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
54
87
 
55
88
  byte[] data = new byte[1024];
56
89
  HAuthTicket hTicket = SteamUser.GetAuthSessionTicket(data, 1024, out uint ticketLength);
57
90
  string ticket = BitConverter.ToString(data, 0, (int)ticketLength)
58
- .Replace("-", string.Empty);
91
+ .Replace("-", string.Empty);
59
92
  tickTasks.TryAdd(hTicket, new Tuple<TaskCompletionSource<string>, string>(tcs, ticket));
60
93
 
61
94
  return tcs.Task;
@@ -66,20 +99,26 @@ namespace XD.SDK.Common.Internal.Standalone {
66
99
  /// </summary>
67
100
  /// <param name="orderId"></param>
68
101
  /// <returns></returns>
69
- public Task<string> GetMicroTxn(ulong orderId) {
70
- // if (!SteamManager.Initialized) {
71
- // throw new Exception("Steam did not initialize.");
72
- // }
102
+ public Task<string> GetMicroTxn(ulong orderId)
103
+ {
104
+ if (!Initialized())
105
+ {
106
+ throw new Exception("Steam did not initialize.");
107
+ }
108
+
73
109
 
74
110
  TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
75
111
  microTxnTasks.TryAdd(orderId, tcs);
76
112
  return tcs.Task;
77
113
  }
78
114
 
79
- public string GetSteamId() {
80
- // if (!SteamManager.Initialized) {
81
- // throw new Exception("Steam did not initialize.");
82
- // }
115
+ public string GetSteamId()
116
+ {
117
+ if (!Initialized())
118
+ {
119
+ throw new Exception("Steam did not initialize.");
120
+ }
121
+
83
122
 
84
123
  try
85
124
  {
@@ -93,18 +132,24 @@ namespace XD.SDK.Common.Internal.Standalone {
93
132
  }
94
133
  }
95
134
 
96
- public string GetSteamLanguage() {
97
- // if (!SteamManager.Initialized) {
98
- // throw new Exception("Steam did not initialize.");
99
- // }
100
-
135
+ public string GetSteamLanguage()
136
+ {
137
+ if (!Initialized())
138
+ {
139
+ throw new Exception("Steam did not initialize.");
140
+ }
141
+
142
+
101
143
  return SteamApps.GetCurrentGameLanguage();
102
144
  }
103
145
 
104
- public string GetSteamCountry() {
105
- // if (!SteamManager.Initialized) {
106
- // throw new Exception("Steam did not initialize.");
107
- // }
146
+ public string GetSteamCountry()
147
+ {
148
+ if (!Initialized())
149
+ {
150
+ throw new Exception("Steam did not initialize.");
151
+ }
152
+
108
153
 
109
154
  try
110
155
  {
@@ -15,7 +15,6 @@ namespace XD.SDK.Common.Internal.Standalone
15
15
 
16
16
  public void Handler(IBridgeWebView webView, string data, Action<object> callbackFunction)
17
17
  {
18
- XDGLogger.Debug($"message from javascript by:{GetName()} with data:{data}");
19
18
  webView.ProviderWebTrans()?.Transparent(Tag, data);
20
19
  }
21
20
  }
@@ -0,0 +1 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
  public class PreloadWebTransmit : IWebTransmit
1
3
  {
2
4
  private readonly Action<WebActionEnum, Dictionary<string, object>> callback;
3
5
  private readonly Action dispose;
4
6
  public PreloadWebTransmit(Action<WebActionEnum, Dictionary<string, object>> callback, Action dispose)
5
7
  {
6
8
  this.dispose = dispose;
7
9
  this.callback = callback;
8
10
  }
9
11
  public void Transparent(string functionName, string data)
10
12
  {
11
13
  }
12
14
  public void TransObserver(WebActionEnum type, Dictionary<string, object> dict)
13
15
  {
14
16
  callback?.Invoke(type, dict);
15
17
  dispose?.Invoke();
16
18
  }
17
19
  }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 66be7c98de7f4406876c3e1d534fb3f6
3
+ timeCreated: 1759997344
@@ -2,9 +2,10 @@
2
2
 
3
3
  using System;
4
4
  using System.Collections.Generic;
5
+ using System.Linq;
6
+ using System.Threading.Tasks;
5
7
  using Newtonsoft.Json;
6
8
  using Vuplex.WebView;
7
- using Task = System.Threading.Tasks.Task;
8
9
 
9
10
  namespace XD.SDK.Common.Internal.Standalone
10
11
  {
@@ -18,27 +19,75 @@ namespace XD.SDK.Common.Internal.Standalone
18
19
  return;
19
20
  }
20
21
 
22
+ {
23
+ var queryParams = ParseQueryString(url);
24
+ var noUI = GetValueOrDefault(queryParams, "xdNoUI", "0") == "1";
25
+ if (noUI)
26
+ {
27
+ PreloadWithCallback(url, callback, true);
28
+ return;
29
+ }
30
+ }
31
+
32
+ XDGLogger.Debug("===> OpenWebPage " + url);
33
+
21
34
  UIManager.ShowUI<XDWebBridgeView>("XDWebBridgeView", new Dictionary<string, object>
22
35
  {
23
36
  { "url", url },
24
37
  { "alpha", 0f },
25
38
  { "interceptor", functions }
26
- }, (code, data) =>
39
+ }, (code, data) => { callback?.Invoke((WebActionEnum)code, JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(data))); });
40
+ }
41
+
42
+ public static void Preload(string url)
43
+ {
44
+ PreloadWithCallback(url, null);
45
+ }
46
+
47
+ private static async void PreloadWithCallback(string url, Action<WebActionEnum, Dictionary<string, object>> callback, bool noUI = false)
48
+ {
49
+ XDGLogger.Debug("===> Preload " + url);
50
+
51
+ try
27
52
  {
28
- callback?.Invoke((WebActionEnum)code,
29
- JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(data)));
30
- });
53
+ var webView = Web.CreateWebView();
54
+ await webView.Init(1, 1);
55
+ var controller = new WebBridgeController(webView, new PreloadWebTransmit(callback, () => webView.Dispose()));
56
+ webView.LoadUrl(url);
57
+ await webView.WaitForNextPageLoadToFinish();
58
+ if (noUI) return;
59
+ await Task.Delay(15 * 1000);
60
+ controller.Release();
61
+ }
62
+ catch (Exception)
63
+ {
64
+ // ignored
65
+ }
66
+ }
67
+
68
+ internal static Dictionary<string, string> ParseQueryString(string url)
69
+ {
70
+ var uri = new Uri(url);
71
+ if (string.IsNullOrWhiteSpace(uri.Query))
72
+ {
73
+ return new Dictionary<string, string>();
74
+ }
75
+
76
+ var dic = uri.Query.Substring(1)
77
+ .Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
78
+ .Select(param => param.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries))
79
+ .GroupBy(part => part[0], part => part.Length > 1 ? part[1] : string.Empty)
80
+ .ToDictionary(group => group.Key, group => string.Join(",", group));
81
+ return dic;
31
82
  }
32
83
 
33
- public static async void Preload(string url)
84
+ internal static TValue GetValueOrDefault<TKey, TValue>(
85
+ Dictionary<TKey, TValue> dictionary,
86
+ TKey key,
87
+ TValue defaultValue)
34
88
  {
35
- var webView = Web.CreateWebView();
36
- await webView.Init(1, 1);
37
- var controller = new WebBridgeController(webView, null);
38
- webView.LoadUrl(url);
39
- await webView.WaitForNextPageLoadToFinish();
40
- await Task.Delay(60 * 1000);
41
- controller.Release();
89
+ if (dictionary == null) return defaultValue;
90
+ return dictionary.TryGetValue(key, out var obj) ? obj : defaultValue;
42
91
  }
43
92
  }
44
93
  }
@@ -73,16 +73,15 @@ namespace XD.SDK.Common.Internal.Standalone
73
73
  canvasWebViewPrefab.WebView.UrlChanged += OnUrlChanged;
74
74
  canvasWebViewPrefab.WebView.PageLoadFailed += OnPageLoadFailed;
75
75
  webBridgeController = new WebBridgeController(canvasWebViewPrefab.WebView, this);
76
- if (extra["interceptor"] != null)
76
+ if (extra != null && extra.TryGetValue("interceptor", out var value))
77
77
  {
78
- List<IWebFunction> interceptorFunctions = extra["interceptor"] as List<IWebFunction>;
78
+ List<IWebFunction> interceptorFunctions = value as List<IWebFunction>;
79
79
  if (interceptorFunctions != null)
80
80
  foreach (var interceptorFunction in interceptorFunctions)
81
81
  {
82
82
  webBridgeController.RegisterHandler(interceptorFunction);
83
83
  }
84
84
  }
85
-
86
85
  Reload();
87
86
  }
88
87
 
@@ -151,12 +150,12 @@ namespace XD.SDK.Common.Internal.Standalone
151
150
 
152
151
  private void ParseUriToInitWebView(string url)
153
152
  {
154
- var queryParams = ParseQueryString(url);
155
- var bgColor = GetValueOrDefault(queryParams, "xdBgColor", WebBridgeConstants.DefaultBgColor);
156
- var close = GetValueOrDefault(queryParams, "xdClose", "1") == "1";
157
- var loading = GetValueOrDefault(queryParams, "xdLoading", "1") == "1";
158
- var nav = GetValueOrDefault(queryParams, "xdNav", "1") == "1";
159
- var title = Uri.UnescapeDataString(GetValueOrDefault(queryParams, "xdTitle", ""));
153
+ var queryParams = WebRequest.ParseQueryString(url);
154
+ var bgColor = WebRequest.GetValueOrDefault(queryParams, "xdBgColor", WebBridgeConstants.DefaultBgColor);
155
+ var close = WebRequest.GetValueOrDefault(queryParams, "xdClose", "1") == "1";
156
+ var loading = WebRequest.GetValueOrDefault(queryParams, "xdLoading", "1") == "1";
157
+ var nav = WebRequest.GetValueOrDefault(queryParams, "xdNav", "1") == "1";
158
+ var title = Uri.UnescapeDataString(WebRequest.GetValueOrDefault(queryParams, "xdTitle", ""));
160
159
 
161
160
  HandlerCloseButtonVisible(new WebCloseButtonBean
162
161
  {
@@ -278,31 +277,6 @@ namespace XD.SDK.Common.Internal.Standalone
278
277
  ColorUtility.TryParseHtmlString(color, out var c);
279
278
  return c;
280
279
  }
281
-
282
- private static Dictionary<string, string> ParseQueryString(string url)
283
- {
284
- var uri = new Uri(url);
285
- if (string.IsNullOrWhiteSpace(uri.Query))
286
- {
287
- return new Dictionary<string, string>();
288
- }
289
-
290
- var dic = uri.Query.Substring(1)
291
- .Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
292
- .Select(param => param.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries))
293
- .GroupBy(part => part[0], part => part.Length > 1 ? part[1] : string.Empty)
294
- .ToDictionary(group => group.Key, group => string.Join(",", group));
295
- return dic;
296
- }
297
-
298
- private static TValue GetValueOrDefault<TKey, TValue>(
299
- IReadOnlyDictionary<TKey, TValue> dictionary,
300
- TKey key,
301
- TValue defaultValue)
302
- {
303
- if (dictionary == null) return defaultValue;
304
- return dictionary.TryGetValue(key, out var obj) ? obj : defaultValue;
305
- }
306
280
  }
307
281
  }
308
282
  #endif
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.xd.sdk.common",
3
3
  "displayName": "XDGSDK Common",
4
- "version": "7.0.2",
4
+ "version": "7.1.1",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.foundation": "7.0.2"
9
+ "com.xd.sdk.foundation": "7.1.1"
10
10
  }
11
11
  }