@aigens/aigens-sdk-core 0.0.12 → 0.0.13
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.
@@ -14,6 +14,8 @@ import Capacitor
|
|
14
14
|
// {themeColor: "#xxxxxx"}
|
15
15
|
public var options: Dictionary<String, Any>?
|
16
16
|
|
17
|
+
private var redirectLink = ""
|
18
|
+
private var universalLink = ""
|
17
19
|
var externalProtocols: [String] = [
|
18
20
|
"octopus://", "alipay://", "alipays://", "alipayhk://", "https://itunes.apple.com", "tel:", "mailto:", "itms-apps://itunes.apple.com", "https://apps.apple.com", "payme://", "weixin://", "hsbcpaymepay://"
|
19
21
|
]
|
@@ -97,6 +99,7 @@ import Capacitor
|
|
97
99
|
let url = URL(string: urlString!)
|
98
100
|
|
99
101
|
let member = self.options?["member"] as? Dictionary<String, Any>
|
102
|
+
self.universalLink = member?["universalLink"] as? String ?? ""
|
100
103
|
|
101
104
|
CorePlugin.member = member
|
102
105
|
let deeplink = self.options?["deeplink"] as? Dictionary<String, Any>
|
@@ -165,6 +168,22 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
165
168
|
return
|
166
169
|
}
|
167
170
|
|
171
|
+
print("navURL--:\(navURL)")
|
172
|
+
|
173
|
+
if !universalLink.isEmpty && navURL.absoluteString.starts(with: universalLink) {
|
174
|
+
|
175
|
+
if navURL.absoluteString.range(of: "redirect=") != nil, let redirect = navURL.absoluteString.components(separatedBy:"redirect=").last, let redirectUrl = URL(string: redirect) {
|
176
|
+
self.redirectLink = redirect
|
177
|
+
print("navURL-- redirect:\(redirect)")
|
178
|
+
webContainerView.showLoading(true)
|
179
|
+
webContainerView.showError(false)
|
180
|
+
let rUrl = URLRequest(url: redirectUrl)
|
181
|
+
webView.load(rUrl)
|
182
|
+
}
|
183
|
+
decisionHandler(.cancel)
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
|
168
187
|
var isCanOpen = false
|
169
188
|
if externalProtocols.count > 0 {
|
170
189
|
externalProtocols.forEach { (url) in
|
@@ -263,7 +282,20 @@ extension WebContainerViewController: WKNavigationDelegate {
|
|
263
282
|
}
|
264
283
|
CAPLog.print("⚡️ WebView failed provisional navigation")
|
265
284
|
CAPLog.print("⚡️ Error: " + error.localizedDescription)
|
266
|
-
|
285
|
+
|
286
|
+
if let errorUrl = webView.url?.absoluteString {
|
287
|
+
print("navURL-- errorUrl: \(errorUrl)")
|
288
|
+
if (!self.redirectLink.isEmpty && errorUrl.starts(with: self.redirectLink)) {
|
289
|
+
self.redirectLink = ""
|
290
|
+
webContainerView.showError(false)
|
291
|
+
webContainerView.showLoading(true)
|
292
|
+
}else {
|
293
|
+
webContainerView.showError(true, error.localizedDescription)
|
294
|
+
}
|
295
|
+
}else {
|
296
|
+
webContainerView.showError(true, error.localizedDescription)
|
297
|
+
}
|
298
|
+
|
267
299
|
}
|
268
300
|
|
269
301
|
public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|