-1

I am currently creating a webView for an App. What I need to do is that when somebody klicks on a link within the webView it needs to open in Safari.

I am doing this in Swift using UIWebView.

In this stackoverflow article I found (UIWebView open links in Safari) I could already find some code that apparently worked for many but I wasn't quite sure what to do with it

1 Answers1

1

UIWbView is dead and Apple will not longer accept it after DEC 2020.

Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs.

Still you want to use UIWebView, you can try with this...

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
            if request.url == request.mainDocumentURL, let url = request.url, UIApplication.shared.canOpenURL(url){
                UIApplication.shared.openURL(url)
                return false
            }
            return true
        }
Sumeet.Jain
  • 1,533
  • 9
  • 26
  • That means after 2020 there will be no way to bring apps to the appstore that have a webview and are also capable of installing on ios 10? – L.Kucznierz Apr 25 '20 at 09:40
  • No, what i meant is app with UIWebView won't be allowed instead use `WKWebView` webkit which supports min iOS 8. I think now it is pretty much cleared – Sumeet.Jain Apr 27 '20 at 09:39
  • yeah, but I have to support really old devices as well, thats the reason why I have to use this old UIWebView, and as long as it will be supported until the end of this year, it's fine! – L.Kucznierz Apr 28 '20 at 10:53