Showing
2 changed files
with
29 additions
and
0 deletions
No preview for this file type
... | @@ -352,6 +352,35 @@ var timer2: DispatchSourceTimer? | ... | @@ -352,6 +352,35 @@ var timer2: DispatchSourceTimer? |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ||
355 | + public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { | ||
356 | + | ||
357 | +// if(navigationAction.navigationType == .linkActivated) { | ||
358 | + | ||
359 | + if let redirectedUrl = navigationAction.request.url { | ||
360 | + // Example Deeplink: https://cosmote.page.link/loyaltyWallet | ||
361 | + // Example Deeplink: https://preview.page.link/cosmote.page.link/loyaltyWallet | ||
362 | + // Example Deeplink: https://apps.apple.com/app/id482889196?mt=8 | ||
363 | + | ||
364 | + if redirectedUrl.absoluteString.contains("cosmote.page.link") { | ||
365 | + | ||
366 | + // check if link can be opened. | ||
367 | + guard UIApplication.shared.canOpenURL(redirectedUrl) else { | ||
368 | + decisionHandler(.cancel) | ||
369 | + return | ||
370 | + } | ||
371 | + | ||
372 | + UIApplication.shared.open(redirectedUrl, options: [:], completionHandler: nil) | ||
373 | + | ||
374 | + decisionHandler(.cancel) | ||
375 | + return | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | +// } | ||
380 | + | ||
381 | + decisionHandler(.allow) | ||
382 | + } | ||
383 | + | ||
355 | // MARK: - WKScriptMessageHandler | 384 | // MARK: - WKScriptMessageHandler |
356 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { | 385 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { |
357 | 386 | ... | ... |
-
Please register or login to post a comment