@aigens/aigens-sdk-core 0.0.39 → 0.0.40
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.
@@ -42,6 +42,8 @@ import java.io.BufferedReader;
|
|
42
42
|
import java.io.IOException;
|
43
43
|
import java.io.InputStream;
|
44
44
|
import java.io.InputStreamReader;
|
45
|
+
import java.io.UnsupportedEncodingException;
|
46
|
+
import java.net.URLDecoder;
|
45
47
|
import java.util.ArrayList;
|
46
48
|
import java.util.Collection;
|
47
49
|
import java.util.HashMap;
|
@@ -80,6 +82,7 @@ public class WebContainerActivity extends BridgeActivity {
|
|
80
82
|
add("payme://");
|
81
83
|
add("https://play.google.com");
|
82
84
|
add("hsbcpaymepay://");
|
85
|
+
add("mpay://");
|
83
86
|
}};
|
84
87
|
|
85
88
|
private void debug(Object... msgs) {
|
@@ -113,7 +116,16 @@ public class WebContainerActivity extends BridgeActivity {
|
|
113
116
|
if (universalLink != null && (totalUrl.startsWith(universalLink) || universalLink.contains("aigens=true")) && totalUrl.indexOf("redirect=") >= 0) {
|
114
117
|
redirectUrl = totalUrl.split("redirect=")[1];
|
115
118
|
}
|
119
|
+
if (universalLink != null && (totalUrl.startsWith(universalLink) || universalLink.contains("aigens=true")) && totalUrl.indexOf("aigensRedirect/") >= 0) {
|
120
|
+
redirectUrl = totalUrl.split("aigensRedirect/")[1];
|
121
|
+
}
|
116
122
|
Log.i("getRedirectUrl", totalUrl);
|
123
|
+
if (redirectUrl != null) {
|
124
|
+
redirectUrl = this.decodeURIComponent(redirectUrl);
|
125
|
+
}
|
126
|
+
if (!redirectUrl.startsWith("http://") && !redirectUrl.startsWith("https://")) {
|
127
|
+
redirectUrl = "https://" + redirectUrl;
|
128
|
+
}
|
117
129
|
return redirectUrl;
|
118
130
|
} else {
|
119
131
|
Log.i("getRedirectUrl", "null");
|
@@ -447,6 +459,15 @@ public class WebContainerActivity extends BridgeActivity {
|
|
447
459
|
return plugins;
|
448
460
|
}
|
449
461
|
|
462
|
+
private String decodeURIComponent(String encodedStr) {
|
463
|
+
String decodedStr = encodedStr;
|
464
|
+
try {
|
465
|
+
decodedStr = URLDecoder.decode(encodedStr, "UTF-8");
|
466
|
+
} catch (UnsupportedEncodingException e) {
|
467
|
+
decodedStr = encodedStr;
|
468
|
+
}
|
469
|
+
return decodedStr;
|
470
|
+
}
|
450
471
|
private boolean isDevMode() {
|
451
472
|
return (this.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
452
473
|
}
|
@@ -752,6 +773,7 @@ public class WebContainerActivity extends BridgeActivity {
|
|
752
773
|
@Override
|
753
774
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
754
775
|
|
776
|
+
// Log.wtf(TAG, "onPageStarted: "+url );
|
755
777
|
debug("onPageStarted", url);
|
756
778
|
|
757
779
|
super.onPageStarted(view, url, favicon);
|
@@ -135,7 +135,9 @@ public class CorePlugin extends Plugin {
|
|
135
135
|
}
|
136
136
|
}
|
137
137
|
|
138
|
-
getActivity()
|
138
|
+
if (getActivity() != null) {
|
139
|
+
getActivity().finish();
|
140
|
+
}
|
139
141
|
|
140
142
|
}
|
141
143
|
|
@@ -159,7 +161,9 @@ public class CorePlugin extends Plugin {
|
|
159
161
|
}
|
160
162
|
}
|
161
163
|
|
162
|
-
getActivity()
|
164
|
+
if (getActivity() != null) {
|
165
|
+
getActivity().finish();
|
166
|
+
}
|
163
167
|
|
164
168
|
|
165
169
|
}
|
@@ -18,7 +18,7 @@ import Capacitor
|
|
18
18
|
private var redirectLink = ""
|
19
19
|
private var universalLink = ""
|
20
20
|
var externalProtocols: [String] = [
|
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://"
|
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://", "mpay://"
|
22
22
|
]
|
23
23
|
var addPaddingProtocols: [String] = [
|
24
24
|
"https://ap-gateway.mastercard.com",
|
@@ -33,8 +33,10 @@ import Capacitor
|
|
33
33
|
"https://web-prd.online.octopus.com.hk",
|
34
34
|
"http://vmp.eftpay.com.cn",
|
35
35
|
"https://wx.tenpay.com",
|
36
|
-
|
37
|
-
|
36
|
+
"https://uatopenapi.macaupay.com.mo",
|
37
|
+
"https://uatpay.macaupass.com",
|
38
|
+
"https://prdpay.macaupass.com",
|
39
|
+
"https://pay.macaupass.com",
|
38
40
|
]
|
39
41
|
|
40
42
|
let containerView = WebContainer.webContainer()
|
@@ -135,10 +137,12 @@ import Capacitor
|
|
135
137
|
}
|
136
138
|
|
137
139
|
aigensprint("handleUrlOpened url:\(object)")
|
138
|
-
guard
|
140
|
+
guard var url = object["url"] as? URL else {
|
139
141
|
return
|
140
142
|
}
|
141
143
|
|
144
|
+
url = decodeURIComponent(url);
|
145
|
+
|
142
146
|
if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
|
143
147
|
return;
|
144
148
|
}
|
@@ -150,6 +154,10 @@ import Capacitor
|
|
150
154
|
aigensprint("handleUniversalLink has -- redirect:\(redirect)")
|
151
155
|
webContainerView.showLoading(true)
|
152
156
|
webContainerView.showError(false)
|
157
|
+
}else if newUrl.absoluteString.range(of: "aigensRedirect/") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty {
|
158
|
+
aigensprint("handleUniversalLink has -- aigensRedirect:\(redirect)")
|
159
|
+
webContainerView.showLoading(true)
|
160
|
+
webContainerView.showError(false)
|
153
161
|
}
|
154
162
|
|
155
163
|
webView?.load(rUrl)
|
@@ -161,10 +169,13 @@ import Capacitor
|
|
161
169
|
}
|
162
170
|
|
163
171
|
aigensprint("handleUniversalLink url:\(object)")
|
164
|
-
guard
|
172
|
+
guard var url = object["url"] as? URL else {
|
165
173
|
return
|
166
174
|
}
|
167
175
|
|
176
|
+
url = decodeURIComponent(url);
|
177
|
+
|
178
|
+
|
168
179
|
if universalLink.isEmpty || (!url.absoluteString.starts(with: universalLink) && !universalLink.contains("aigens=true")) {
|
169
180
|
return;
|
170
181
|
}
|
@@ -177,6 +188,10 @@ import Capacitor
|
|
177
188
|
aigensprint("handleUniversalLink has -- redirect:\(redirect)")
|
178
189
|
webContainerView.showLoading(true)
|
179
190
|
webContainerView.showError(false)
|
191
|
+
}else if newUrl.absoluteString.range(of: "aigensRedirect/") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty {
|
192
|
+
aigensprint("handleUniversalLink has -- aigensRedirect:\(redirect)")
|
193
|
+
webContainerView.showLoading(true)
|
194
|
+
webContainerView.showError(false)
|
180
195
|
}
|
181
196
|
|
182
197
|
|
@@ -238,6 +253,16 @@ import Capacitor
|
|
238
253
|
|
239
254
|
}
|
240
255
|
|
256
|
+
private func decodeURIComponent(_ url: URL) -> URL {
|
257
|
+
let str = url.absoluteString
|
258
|
+
let urlStr = str.removingPercentEncoding ?? str
|
259
|
+
return URL(string: urlStr) ?? url
|
260
|
+
}
|
261
|
+
|
262
|
+
private func decodeURIComponent(_ str: String) -> String {
|
263
|
+
return str.removingPercentEncoding ?? str
|
264
|
+
}
|
265
|
+
|
241
266
|
public final func loadWebViewCustom() {
|
242
267
|
|
243
268
|
//let bridge = self.bridge
|
@@ -245,6 +270,13 @@ import Capacitor
|
|
245
270
|
|
246
271
|
|
247
272
|
let urlString = self.options?["url"] as? String;
|
273
|
+
// urlString = "https://payment2.pizzahut.com.hk/v3/Payment/Completed?TransId=N224A2306130302&Code=4F19FC65-E099-4339-ADF4-3986EF539233"
|
274
|
+
// urlString = "https://payment2.pizzahut.com.hk/v3/Payment/UserCancel?TransId=N224A2306130301&Code=44D4B103-4962-432E-A323-086D46F8BB6F"
|
275
|
+
// urlString = "https://payment2.pizzahut.com.hk/v3/Payment/Completed?TransId=A224A2306131102&Code=104A53FB-053E-4FC1-870E-29D7B39AE2C5"
|
276
|
+
|
277
|
+
// urlString = "https%3a%2f%2fpayment2.pizzahut.com.hk%2fv3%2fPayment%2fCompleted%3fTransId%3dA224A2306131102%26Code%3d104A53FB-053E-4FC1-870E-29D7B39AE2C5";
|
278
|
+
//
|
279
|
+
// urlString = decodeURIComponent(urlString!)
|
248
280
|
|
249
281
|
if(urlString == nil){
|
250
282
|
return;
|
@@ -343,15 +375,36 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
343
375
|
aigensprint("navURL--:\(navURL)")
|
344
376
|
if !universalLink.isEmpty && (navURL.absoluteString.starts(with: universalLink) || universalLink.contains("aigens=true")) {
|
345
377
|
|
346
|
-
if navURL.absoluteString.range(of: "redirect=") != nil,
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
378
|
+
if navURL.absoluteString.range(of: "redirect=") != nil, var redirect = navURL.absoluteString.components(separatedBy:"redirect=").last{
|
379
|
+
if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
|
380
|
+
redirect = "https://" + redirect
|
381
|
+
}
|
382
|
+
if let redirectUrl = URL(string: redirect) {
|
383
|
+
self.redirectLink = redirect
|
384
|
+
aigensprint("navURL-- redirect:\(redirect)")
|
385
|
+
webContainerView.showLoading(true)
|
386
|
+
webContainerView.showError(false)
|
387
|
+
let rUrl = URLRequest(url: redirectUrl)
|
388
|
+
webView.load(rUrl)
|
389
|
+
decisionHandler(.cancel)
|
390
|
+
return;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
if navURL.absoluteString.range(of: "aigensRedirect/") != nil, var redirect = navURL.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty{
|
395
|
+
if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
|
396
|
+
redirect = "https://" + redirect
|
397
|
+
}
|
398
|
+
if let redirectUrl = URL(string: redirect) {
|
399
|
+
self.redirectLink = redirect
|
400
|
+
aigensprint("navURL-- aigensRedirect:\(redirect)")
|
401
|
+
webContainerView.showLoading(true)
|
402
|
+
webContainerView.showError(false)
|
403
|
+
let rUrl = URLRequest(url: redirectUrl)
|
404
|
+
webView.load(rUrl)
|
405
|
+
decisionHandler(.cancel)
|
406
|
+
return;
|
407
|
+
}
|
355
408
|
}
|
356
409
|
|
357
410
|
}
|
@@ -431,12 +484,20 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
431
484
|
if (bg && bg[0]) {
|
432
485
|
bg[0].style.paddingTop = "\(UIDevice.xp_statusBarHeight())px";
|
433
486
|
}
|
487
|
+
|
488
|
+
let app = document.querySelector('body>#app');
|
489
|
+
if (app && window) {
|
490
|
+
if (window.getComputedStyle(app).position == 'absolute') {
|
491
|
+
app.style.top = "\(UIDevice.xp_statusBarHeight())px";
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
434
495
|
""")
|
435
496
|
}
|
436
497
|
|
437
498
|
webContainerView.showLoading(false)
|
438
499
|
webContainerView.showError(false)
|
439
|
-
CAPLog.print("⚡️ WebView loaded")
|
500
|
+
CAPLog.print("⚡️ WebView loaded:\(webView.url)")
|
440
501
|
}
|
441
502
|
|
442
503
|
// The force unwrap is part of the protocol declaration, so we should keep it.
|
@@ -547,7 +608,7 @@ extension UIDevice {
|
|
547
608
|
} else {
|
548
609
|
statusBarHeight = UIApplication.shared.statusBarFrame.height
|
549
610
|
}
|
550
|
-
print("navURL-- height:\(statusBarHeight)")
|
611
|
+
CAPLog.print("navURL-- height:\(statusBarHeight)")
|
551
612
|
return statusBarHeight
|
552
613
|
}
|
553
614
|
|