Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop WKWebView redirecting to another app based on Universal link

We are using WKWebview to custom load and manage our ServiceNow instance, but however while login succeeds, if user has "ServiceNow" mobile app installed post login it opens ServiceNow app.

Tried blocking the final Url navigation action(decidePolicyfor navigationAction) without success.

It's happening due to Universal link at ServiceNow end. http://service-now.com/apple-app-site-association

Any ways to block this operation at our end.

like image 223
ibiren Avatar asked Sep 19 '18 10:09

ibiren


1 Answers

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {

    decisionHandler(WKNavigationActionPolicy(rawValue: WKNavigationActionPolicy.allow.rawValue + 2)!)
}

This seems to solve the issue.

like image 180
ibiren Avatar answered Nov 06 '22 22:11

ibiren