Permalink
Browse files

Fixed problems with opening links iOS

  • Loading branch information...
Miggets7 committed Nov 27, 2017
1 parent 7dc8a0c commit c3790b5e5e0814cd3e053dd19df75c22cd660ccb
Showing with 11 additions and 3 deletions.
  1. +11 −3 console/iOS/console/ORViewController.swift
@@ -74,17 +74,25 @@ class ORViewcontroller : UIViewController, URLSessionDelegate, WKScriptMessageHa
completionHandler(exec_template)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if (navigationAction.request.url?.absoluteString.contains("logout"))! {
TokenManager.sharedInstance.logout()
decisionHandler(.cancel)
self.dismiss(animated: false, completion: nil)
} else {
decisionHandler(.allow)
let app = UIApplication.shared
if navigationAction.targetFrame == nil, let url = navigationAction.request.url{
if app.canOpenURL(url) {
app.open(url, options: [:], completionHandler: nil)
decisionHandler(.cancel)
}
} else {
decisionHandler(.allow)
}
}
}
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
if let response = navigationResponse.response as? HTTPURLResponse {
if response.statusCode != 200 && response.statusCode != 204 {

0 comments on commit c3790b5

Please sign in to comment.