@aigens/aigens-sdk-core 0.0.38 → 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
|
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,22 @@ 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
|
+
|
125
145
|
private void addChannel() {
|
126
146
|
if (getIntent() == null) return;
|
127
147
|
String url = getIntent().getStringExtra("url");
|
@@ -144,9 +164,9 @@ public class WebContainerActivity extends BridgeActivity {
|
|
144
164
|
|
145
165
|
setContentView(com.aigens.sdk.R.layout.sdk_layout_main);
|
146
166
|
|
147
|
-
String redirectUrl = getRedirectUrl();
|
148
167
|
Intent intent = getIntent();
|
149
168
|
|
169
|
+
String redirectUrl = getRedirectUrl(intent);
|
150
170
|
if (redirectUrl != null && !redirectUrl.equals("") && WebContainerActivity.perviousIntent != null) {
|
151
171
|
WebContainerActivity.perviousIntent.putExtra("url", redirectUrl);
|
152
172
|
intent = WebContainerActivity.perviousIntent;
|
@@ -266,7 +286,7 @@ public class WebContainerActivity extends BridgeActivity {
|
|
266
286
|
this.bridge.getWebView().setWebViewClient(wvc);
|
267
287
|
if (DEBUG) {
|
268
288
|
this.bridge.getWebView().setWebContentsDebuggingEnabled(true);
|
269
|
-
}else {
|
289
|
+
} else {
|
270
290
|
this.bridge.getWebView().setWebContentsDebuggingEnabled(false);
|
271
291
|
}
|
272
292
|
|
@@ -752,7 +772,7 @@ public class WebContainerActivity extends BridgeActivity {
|
|
752
772
|
@Override
|
753
773
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
754
774
|
debug("onReceivedErrorOld", errorCode, description, failingUrl);
|
755
|
-
System.out.println("onReceivedErrorOld:"+description+failingUrl);
|
775
|
+
System.out.println("onReceivedErrorOld:" + description + failingUrl);
|
756
776
|
if (isFirstError) { // reload
|
757
777
|
isFirstError = false;
|
758
778
|
reload();
|
@@ -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
|
@@ -50,6 +67,15 @@ import Capacitor
|
|
50
67
|
|
51
68
|
}
|
52
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
|
+
}
|
53
79
|
private func addChannel() {
|
54
80
|
if let urlString = self.options?["url"] as? String {
|
55
81
|
|
@@ -113,7 +139,7 @@ import Capacitor
|
|
113
139
|
return
|
114
140
|
}
|
115
141
|
|
116
|
-
if universalLink.isEmpty || !url.absoluteString.starts(with: universalLink) {
|
142
|
+
if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
|
117
143
|
return;
|
118
144
|
}
|
119
145
|
|
@@ -139,7 +165,7 @@ import Capacitor
|
|
139
165
|
return
|
140
166
|
}
|
141
167
|
|
142
|
-
if universalLink.isEmpty || !url.absoluteString.starts(with: universalLink) {
|
168
|
+
if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
|
143
169
|
return;
|
144
170
|
}
|
145
171
|
|
@@ -206,6 +232,10 @@ import Capacitor
|
|
206
232
|
self.externalProtocols.append(contentsOf: externalProtocols)
|
207
233
|
}
|
208
234
|
|
235
|
+
if let addPaddingProtocols = options?["addPaddingProtocols"] as? [String] {
|
236
|
+
self.addPaddingProtocols.append(contentsOf: addPaddingProtocols)
|
237
|
+
}
|
238
|
+
|
209
239
|
}
|
210
240
|
|
211
241
|
public final func loadWebViewCustom() {
|
@@ -311,8 +341,7 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
311
341
|
}
|
312
342
|
|
313
343
|
aigensprint("navURL--:\(navURL)")
|
314
|
-
|
315
|
-
if !universalLink.isEmpty && navURL.absoluteString.starts(with: universalLink) {
|
344
|
+
if !universalLink.isEmpty && (navURL.absoluteString.starts(with: universalLink) || universalLink.contains("aigens=true")) {
|
316
345
|
|
317
346
|
if navURL.absoluteString.range(of: "redirect=") != nil, let redirect = navURL.absoluteString.components(separatedBy:"redirect=").last, let redirectUrl = URL(string: redirect) {
|
318
347
|
self.redirectLink = redirect
|
@@ -321,9 +350,10 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
321
350
|
webContainerView.showError(false)
|
322
351
|
let rUrl = URLRequest(url: redirectUrl)
|
323
352
|
webView.load(rUrl)
|
353
|
+
decisionHandler(.cancel)
|
354
|
+
return;
|
324
355
|
}
|
325
|
-
|
326
|
-
return;
|
356
|
+
|
327
357
|
}
|
328
358
|
|
329
359
|
var isCanOpen = false
|
@@ -394,6 +424,16 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
394
424
|
// webView.isOpaque = isOpaque
|
395
425
|
// webViewLoadingState = .subsequentLoad
|
396
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
|
+
|
397
437
|
webContainerView.showLoading(false)
|
398
438
|
webContainerView.showError(false)
|
399
439
|
CAPLog.print("⚡️ WebView loaded")
|
@@ -464,3 +504,70 @@ extension UIColor {
|
|
464
504
|
alpha: alpha);
|
465
505
|
}
|
466
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
|
+
}
|