tel not open call ios webview swift

 Problem:

I want to open telephone call option ahile add numbers as link in webview.How can i achieve that?


Solution:

public func webView(_ webView: WKWebViewdecidePolicyFor navigationAction: WKNavigationActiondecisionHandler@escaping (WKNavigationActionPolicy) -> Void) {

        if navigationAction.request.url?.scheme == "tel" {

            UIApplication.shared.open(navigationAction.request.url!)

            return decisionHandler(.cancel)

        } else {

            return decisionHandler(WKNavigationActionPolicy.allow);

        }

}


Use the above code to achieve that.While tap on the link it will show you telephone call option.

Comments

Popular posts from this blog

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift