@aigens/aigens-sdk-core 0.0.37 → 0.0.39

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.
@@ -93,9 +93,9 @@ public class WebContainerActivity extends BridgeActivity {
93
93
  }
94
94
  }
95
95
 
96
- private String getRedirectUrl() {
96
+ private String getRedirectUrl(Intent intent) {
97
97
  try {
98
- Intent intent = getIntent();
98
+ // Intent intent = getIntent();
99
99
  Uri uri = intent.getData();
100
100
  if (uri != null) {
101
101
  String totalUrl = uri.toString();
@@ -104,9 +104,13 @@ public class WebContainerActivity extends BridgeActivity {
104
104
  if (perviousIntent != null) {
105
105
  Map member = (Map) perviousIntent.getSerializableExtra("member");
106
106
  universalLink = (String) member.get("universalLink");
107
- universalLink = universalLink.trim();
107
+ if (universalLink != null && !universalLink.isEmpty()) {
108
+ universalLink = universalLink.trim();
109
+ }else {
110
+ universalLink = null;
111
+ }
108
112
  }
109
- if (universalLink != null && totalUrl.startsWith(universalLink) && totalUrl.indexOf("redirect=") >= 0) {
113
+ if (universalLink != null && (totalUrl.startsWith(universalLink) || universalLink.contains("aigens=true")) && totalUrl.indexOf("redirect=") >= 0) {
110
114
  redirectUrl = totalUrl.split("redirect=")[1];
111
115
  }
112
116
  Log.i("getRedirectUrl", totalUrl);
@@ -122,6 +126,33 @@ public class WebContainerActivity extends BridgeActivity {
122
126
 
123
127
  }
124
128
 
129
+
130
+ @Override
131
+ protected void onNewIntent(Intent intent) {
132
+ super.onNewIntent(intent);
133
+ // System.out.println("OPEN URL: onNewIntent" + intent.toString());
134
+ String redirectUrl = getRedirectUrl(intent);
135
+ if (redirectUrl != null) {
136
+ if (this.bridge != null && this.bridge.getWebView() != null) {
137
+ initLayout(false, true, false);
138
+ this.bridge.getWebView().loadUrl(redirectUrl);
139
+ }
140
+ }
141
+
142
+
143
+ }
144
+
145
+ private void addChannel() {
146
+ if (getIntent() == null) return;
147
+ String url = getIntent().getStringExtra("url");
148
+ if (url != null) {
149
+ if (!url.contains("&channel=app") && !url.contains("?channel=app")) {
150
+ String sign = url.contains("?") ? "&" : "?";
151
+ getIntent().putExtra("url", url + sign + "channel=app");
152
+ }
153
+ }
154
+ }
155
+
125
156
  @Override
126
157
  protected void onCreate(Bundle savedInstanceState) {
127
158
 
@@ -129,12 +160,13 @@ public class WebContainerActivity extends BridgeActivity {
129
160
 
130
161
  super.onCreate(currentInstanceState);
131
162
 
132
- setContentView(com.aigens.sdk.R.layout.sdk_layout_main);
163
+ addChannel();
133
164
 
165
+ setContentView(com.aigens.sdk.R.layout.sdk_layout_main);
134
166
 
135
- String redirectUrl = getRedirectUrl();
136
167
  Intent intent = getIntent();
137
168
 
169
+ String redirectUrl = getRedirectUrl(intent);
138
170
  if (redirectUrl != null && !redirectUrl.equals("") && WebContainerActivity.perviousIntent != null) {
139
171
  WebContainerActivity.perviousIntent.putExtra("url", redirectUrl);
140
172
  intent = WebContainerActivity.perviousIntent;
@@ -146,6 +178,8 @@ public class WebContainerActivity extends BridgeActivity {
146
178
 
147
179
  this.url = intent.getStringExtra("url");
148
180
 
181
+ Log.i("getStringExtra url:", url);
182
+
149
183
  // TEST
150
184
  // this.url = "http://192.168.100.66:4200/crm/brand/220000/directory";
151
185
 
@@ -252,7 +286,7 @@ public class WebContainerActivity extends BridgeActivity {
252
286
  this.bridge.getWebView().setWebViewClient(wvc);
253
287
  if (DEBUG) {
254
288
  this.bridge.getWebView().setWebContentsDebuggingEnabled(true);
255
- }else {
289
+ } else {
256
290
  this.bridge.getWebView().setWebContentsDebuggingEnabled(false);
257
291
  }
258
292
 
@@ -536,9 +570,14 @@ public class WebContainerActivity extends BridgeActivity {
536
570
 
537
571
  try {
538
572
  JSONObject plugins = jo.optJSONObject("plugins");
539
- JSONObject splashScreen = plugins.optJSONObject("SplashScreen");
540
- splashScreen.putOpt("launchShowDuration", 0);
541
- splashScreen.putOpt("launchAutoHide", true);
573
+ if (plugins != null) {
574
+ JSONObject splashScreen = plugins.optJSONObject("SplashScreen");
575
+ if (splashScreen != null) {
576
+ splashScreen.putOpt("launchShowDuration", 0);
577
+ splashScreen.putOpt("launchAutoHide", true);
578
+ }
579
+ }
580
+
542
581
  } catch (JSONException e) {
543
582
  e.printStackTrace();
544
583
  }
@@ -733,7 +772,7 @@ public class WebContainerActivity extends BridgeActivity {
733
772
  @Override
734
773
  public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
735
774
  debug("onReceivedErrorOld", errorCode, description, failingUrl);
736
- System.out.println("onReceivedErrorOld:"+description+failingUrl);
775
+ System.out.println("onReceivedErrorOld:" + description + failingUrl);
737
776
  if (isFirstError) { // reload
738
777
  isFirstError = false;
739
778
  reload();
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAY;;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,MAAM,eAAG,CAAC,CAAC,MAAM,0CAAE,OAAO,0CAAE,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAAY;;QAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,QAAQ,eAAG,CAAC,CAAC,MAAM,0CAA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AC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;aACpF;YAAC,OAAO,KAAK,EAAE;aACf;SACJ;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,aAAa;QACf,IACI,OAAO,SAAS,KAAK,WAAW;YAChC,CAAC,SAAS,CAAC,SAAS;YACpB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAC/B;YACE,MAAM,IAAI,CAAC,WAAW,CAClB,sDAAsD,CACzD,CAAC;SACL;QAED,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAC/C,CAAC;CAEJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { CorePlugin, Deeplink, Member, PermissionStatus } from './definitions';\n\n\nexport class CoreWeb extends WebPlugin implements CorePlugin {\n async echo(options: any): Promise<any> {\n console.log('ECHO', options);\n return options;\n }\n\n async getMember(options: any): Promise<{ member: Member }> {\n console.log('GET MEMBER', options);\n var result = {} as any;\n var w = window as any;\n result.member = w.aigens?.context?.member;\n return result;\n }\n async getDeeplink(options: any): Promise<{ deeplink: Deeplink }> {\n console.log('GET Deeplink', options);\n var result = {} as any;\n var w = window as any;\n result.deeplink = w.aigens?.context?.deeplink;\n return result;\n }\n\n async dismiss(options: any): Promise<any> {\n console.log('DISMISS', options);\n return options;\n }\n\n async finish(options: any): Promise<any> {\n console.log('FINISH', options);\n return options;\n }\n\n async openBrowser(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async isInstalledApp(options: { key: string }): Promise<{ install: boolean }> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async openExternalUrl(options: { url: string }): Promise<any> {\n window.open(options.url, \"_blank\");\n return {\n open: true\n }\n }\n\n async getIsProductionEnvironment(): Promise<{ isPrd: boolean }> {\n return { isPrd: true };\n }\n\n async checkNotificationPermissions(): Promise<PermissionStatus> {\n throw new Error('checkNotificationPermissions not supported in browser.');\n }\n\n async getFinishData(options: any): Promise<{ closedData: any }> {\n return { closedData: options }\n }\n\n async setTextZoom(options: { value: number }): Promise<any> {\n if (typeof document !== 'undefined') {\n try {\n document.body.style.webkitTextSizeAdjust = `${Math.round(options.value * 100)}%`;\n } catch (error) {\n }\n }\n return options;\n }\n\n async readClipboard(): Promise<any> {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText\n ) {\n throw this.unavailable(\n 'Reading from clipboard not supported in this browser',\n );\n }\n\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAY;;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,MAAM,GAAG,MAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,OAAO,0CAAE,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAAY;;QAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM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C,IAAI,CAAC,KAAK,CAAC,oBAAoB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;aACpF;YAAC,OAAO,KAAK,EAAE;aACf;SACJ;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,aAAa;QACf,IACI,OAAO,SAAS,KAAK,WAAW;YAChC,CAAC,SAAS,CAAC,SAAS;YACpB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAC/B;YACE,MAAM,IAAI,CAAC,WAAW,CAClB,sDAAsD,CACzD,CAAC;SACL;QAED,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAC/C,CAAC;CAEJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { CorePlugin, Deeplink, Member, PermissionStatus } from './definitions';\n\n\nexport class CoreWeb extends WebPlugin implements CorePlugin {\n async echo(options: any): Promise<any> {\n console.log('ECHO', options);\n return options;\n }\n\n async getMember(options: any): Promise<{ member: Member }> {\n console.log('GET MEMBER', options);\n var result = {} as any;\n var w = window as any;\n result.member = w.aigens?.context?.member;\n return result;\n }\n async getDeeplink(options: any): Promise<{ deeplink: Deeplink }> {\n console.log('GET Deeplink', options);\n var result = {} as any;\n var w = window as any;\n result.deeplink = w.aigens?.context?.deeplink;\n return result;\n }\n\n async dismiss(options: any): Promise<any> {\n console.log('DISMISS', options);\n return options;\n }\n\n async finish(options: any): Promise<any> {\n console.log('FINISH', options);\n return options;\n }\n\n async openBrowser(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async isInstalledApp(options: { key: string }): Promise<{ install: boolean }> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n async openExternalUrl(options: { url: string }): Promise<any> {\n window.open(options.url, \"_blank\");\n return {\n open: true\n }\n }\n\n async getIsProductionEnvironment(): Promise<{ isPrd: boolean }> {\n return { isPrd: true };\n }\n\n async checkNotificationPermissions(): Promise<PermissionStatus> {\n throw new Error('checkNotificationPermissions not supported in browser.');\n }\n\n async getFinishData(options: any): Promise<{ closedData: any }> {\n return { closedData: options }\n }\n\n async setTextZoom(options: { value: number }): Promise<any> {\n if (typeof document !== 'undefined') {\n try {\n document.body.style.webkitTextSizeAdjust = `${Math.round(options.value * 100)}%`;\n } catch (error) {\n }\n }\n return options;\n }\n\n async readClipboard(): Promise<any> {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText\n ) {\n throw this.unavailable(\n 'Reading from clipboard not supported in this browser',\n );\n }\n\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n\n}\n"]}
@@ -164,6 +164,8 @@ public class CorePlugin: CAPPlugin {
164
164
  let member = call.getObject("member")
165
165
  let deeplink = call.getObject("deeplink")
166
166
  let externalProtocols = call.getArray("externalProtocols")
167
+ let addPaddingProtocols = call.getArray("addPaddingProtocols")
168
+
167
169
  let clearCache = call.getBool("clearCache") ?? false
168
170
  aigensDebug = call.getBool("debug") ?? false
169
171
 
@@ -186,6 +188,9 @@ public class CorePlugin: CAPPlugin {
186
188
  if (externalProtocols != nil) {
187
189
  options["externalProtocols"] = externalProtocols as AnyObject
188
190
  }
191
+ if (addPaddingProtocols != nil) {
192
+ options["addPaddingProtocols"] = addPaddingProtocols as AnyObject
193
+ }
189
194
 
190
195
  bridgeVC.options = options;
191
196
 
@@ -266,7 +271,7 @@ public class CorePlugin: CAPPlugin {
266
271
  @objc func setTextZoom(_ call: CAPPluginCall) {
267
272
  call.unimplemented("ios does not implement.")
268
273
  }
269
-
274
+
270
275
  private func getStringFromQr(_ image: UIImage) -> String? {
271
276
  guard let ciImage = CIImage(image: image) else {
272
277
  return nil
@@ -18,8 +18,25 @@ import Capacitor
18
18
  private var redirectLink = ""
19
19
  private var universalLink = ""
20
20
  var externalProtocols: [String] = [
21
- "octopus://", "alipay://", "alipays://", "alipayhk://", "https://itunes.apple.com", "tel:", "mailto:", "itms-apps://itunes.apple.com", "https://apps.apple.com", "payme://", "weixin://", "hsbcpaymepay://"
21
+ "octopus://", "alipay://", "alipays://", "alipayhk://", "https://play.google.com", "https://itunes.apple.com", "tel:", "mailto:", "itms-apps://itunes.apple.com", "https://apps.apple.com", "payme://", "weixin://", "hsbcpaymepay://"
22
22
  ]
23
+ var addPaddingProtocols: [String] = [
24
+ "https://ap-gateway.mastercard.com",
25
+ "https://mapi-hk.alipay.com/",
26
+ "https://mclient.alipay.com/",
27
+ "https://tscenter.alipay.com/",
28
+ "https://test.paydollar.com/",
29
+ "https://paydollar.com/",
30
+ "https://www.paydollar.com/",
31
+ "https://web-test.online.octopus.com.hk",
32
+ "https://web.online.octopus.com.hk",
33
+ "https://web-prd.online.octopus.com.hk",
34
+ "http://vmp.eftpay.com.cn",
35
+ "https://wx.tenpay.com",
36
+
37
+
38
+ ]
39
+
23
40
  let containerView = WebContainer.webContainer()
24
41
  var webContainerView: WebContainer {
25
42
  return containerView
@@ -29,6 +46,8 @@ import Capacitor
29
46
  aigensprint("WebContainerViewController viewDidLoad")
30
47
 
31
48
  self.becomeFirstResponder()
49
+
50
+ addChannel()
32
51
  loadWebViewCustom()
33
52
  initView()
34
53
 
@@ -48,6 +67,25 @@ import Capacitor
48
67
 
49
68
  }
50
69
 
70
+ private func isPaddingUrl(_ url: URL) -> Bool {
71
+ var result = false
72
+ addPaddingProtocols.forEach { (url_) in
73
+ if (url.absoluteString.starts(with: url_)) {
74
+ result = true
75
+ }
76
+ }
77
+ return result
78
+ }
79
+ private func addChannel() {
80
+ if let urlString = self.options?["url"] as? String {
81
+
82
+ if !urlString.contains("&channel=app") && !urlString.contains("?channel=app") {
83
+ let sign = urlString.contains("?") ? "&" : "?"
84
+ self.options?["url"] = urlString + sign + "channel=app"
85
+ }
86
+ }
87
+ }
88
+
51
89
  private func clearCache() {
52
90
  if #available(iOS 9.0, *) {
53
91
  /*
@@ -101,11 +139,19 @@ import Capacitor
101
139
  return
102
140
  }
103
141
 
104
- if universalLink.isEmpty || !url.absoluteString.starts(with: universalLink) {
142
+ if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
105
143
  return;
106
144
  }
107
145
 
108
146
  let rUrl = URLRequest(url: url)
147
+
148
+ let newUrl = url;
149
+ if newUrl.absoluteString.range(of: "redirect=") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"redirect=").last, !redirect.isEmpty {
150
+ aigensprint("handleUniversalLink has -- redirect:\(redirect)")
151
+ webContainerView.showLoading(true)
152
+ webContainerView.showError(false)
153
+ }
154
+
109
155
  webView?.load(rUrl)
110
156
  }
111
157
 
@@ -119,7 +165,7 @@ import Capacitor
119
165
  return
120
166
  }
121
167
 
122
- if universalLink.isEmpty || !url.absoluteString.starts(with: universalLink) {
168
+ if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
123
169
  return;
124
170
  }
125
171
 
@@ -186,6 +232,10 @@ import Capacitor
186
232
  self.externalProtocols.append(contentsOf: externalProtocols)
187
233
  }
188
234
 
235
+ if let addPaddingProtocols = options?["addPaddingProtocols"] as? [String] {
236
+ self.addPaddingProtocols.append(contentsOf: addPaddingProtocols)
237
+ }
238
+
189
239
  }
190
240
 
191
241
  public final func loadWebViewCustom() {
@@ -291,8 +341,7 @@ extension WebContainerViewController: WKNavigationDelegate {
291
341
  }
292
342
 
293
343
  aigensprint("navURL--:\(navURL)")
294
-
295
- if !universalLink.isEmpty && navURL.absoluteString.starts(with: universalLink) {
344
+ if !universalLink.isEmpty && (navURL.absoluteString.starts(with: universalLink) || universalLink.contains("aigens=true")) {
296
345
 
297
346
  if navURL.absoluteString.range(of: "redirect=") != nil, let redirect = navURL.absoluteString.components(separatedBy:"redirect=").last, let redirectUrl = URL(string: redirect) {
298
347
  self.redirectLink = redirect
@@ -301,9 +350,10 @@ extension WebContainerViewController: WKNavigationDelegate {
301
350
  webContainerView.showError(false)
302
351
  let rUrl = URLRequest(url: redirectUrl)
303
352
  webView.load(rUrl)
353
+ decisionHandler(.cancel)
354
+ return;
304
355
  }
305
- decisionHandler(.cancel)
306
- return;
356
+
307
357
  }
308
358
 
309
359
  var isCanOpen = false
@@ -374,6 +424,16 @@ extension WebContainerViewController: WKNavigationDelegate {
374
424
  // webView.isOpaque = isOpaque
375
425
  // webViewLoadingState = .subsequentLoad
376
426
  // }
427
+
428
+ if let navURL = webView.url, isPaddingUrl(navURL) {
429
+ webView.evaluateJavaScript("""
430
+ let bg = document.getElementsByTagName('body');
431
+ if (bg && bg[0]) {
432
+ bg[0].style.paddingTop = "\(UIDevice.xp_statusBarHeight())px";
433
+ }
434
+ """)
435
+ }
436
+
377
437
  webContainerView.showLoading(false)
378
438
  webContainerView.showError(false)
379
439
  CAPLog.print("⚡️ WebView loaded")
@@ -444,3 +504,70 @@ extension UIColor {
444
504
  alpha: alpha);
445
505
  }
446
506
  }
507
+
508
+
509
+ extension UIDevice {
510
+
511
+ /// 顶部安全区高度
512
+ static func xp_safeDistanceTop() -> CGFloat {
513
+ if #available(iOS 13.0, *) {
514
+ let scene = UIApplication.shared.connectedScenes.first
515
+ guard let windowScene = scene as? UIWindowScene else { return 0 }
516
+ guard let window = windowScene.windows.first else { return 0 }
517
+ return window.safeAreaInsets.top
518
+ } else if #available(iOS 11.0, *) {
519
+ guard let window = UIApplication.shared.windows.first else { return 0 }
520
+ return window.safeAreaInsets.top
521
+ }
522
+ return 0;
523
+ }
524
+
525
+ /// 底部安全区高度
526
+ static func xp_safeDistanceBottom() -> CGFloat {
527
+ if #available(iOS 13.0, *) {
528
+ let scene = UIApplication.shared.connectedScenes.first
529
+ guard let windowScene = scene as? UIWindowScene else { return 0 }
530
+ guard let window = windowScene.windows.first else { return 0 }
531
+ return window.safeAreaInsets.bottom
532
+ } else if #available(iOS 11.0, *) {
533
+ guard let window = UIApplication.shared.windows.first else { return 0 }
534
+ return window.safeAreaInsets.bottom
535
+ }
536
+ return 0;
537
+ }
538
+
539
+ /// 顶部状态栏高度(包括安全区)
540
+ static func xp_statusBarHeight() -> CGFloat {
541
+ var statusBarHeight: CGFloat = 0
542
+ if #available(iOS 13.0, *) {
543
+ let scene = UIApplication.shared.connectedScenes.first
544
+ guard let windowScene = scene as? UIWindowScene else { return 0 }
545
+ guard let statusBarManager = windowScene.statusBarManager else { return 0 }
546
+ statusBarHeight = statusBarManager.statusBarFrame.height
547
+ } else {
548
+ statusBarHeight = UIApplication.shared.statusBarFrame.height
549
+ }
550
+ print("navURL-- height:\(statusBarHeight)")
551
+ return statusBarHeight
552
+ }
553
+
554
+ /// 导航栏高度
555
+ static func xp_navigationBarHeight() -> CGFloat {
556
+ return 44.0
557
+ }
558
+
559
+ /// 状态栏+导航栏的高度
560
+ static func xp_navigationFullHeight() -> CGFloat {
561
+ return UIDevice.xp_statusBarHeight() + UIDevice.xp_navigationBarHeight()
562
+ }
563
+
564
+ /// 底部导航栏高度
565
+ static func xp_tabBarHeight() -> CGFloat {
566
+ return 49.0
567
+ }
568
+
569
+ /// 底部导航栏高度(包括安全区)
570
+ static func xp_tabBarFullHeight() -> CGFloat {
571
+ return UIDevice.xp_tabBarHeight() + UIDevice.xp_safeDistanceBottom()
572
+ }
573
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -57,7 +57,7 @@
57
57
  "rimraf": "^3.0.2",
58
58
  "rollup": "^2.32.0",
59
59
  "swiftlint": "^1.0.1",
60
- "typescript": "~4.1.5"
60
+ "typescript": "~4.8"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@capacitor/core": "^3.0.0"