Home > Back-end >  Select file button is not opening the files library in webView of iOS
Select file button is not opening the files library in webView of iOS

Time:11-22

I have select file button in website which is opening in webview in my iOS application but the button is not opening the files library of iOS device. but the same link is working fine for android and even in desktop browser

I just used the webView simply and tried some delegate methods to listen the click but I am not able to found any method to work in this situation.

    if let myUrl: URL = URL(string: urlWeb){
                        webViewTerms.delegate = self
            webViewTerms.loadRequest(URLRequest(url: myUrl))
        }

CodePudding user response:

I suppose you have the below code in your website to listen the click event. Adding a href to your button event

"window.location.href = “ myapp://click”;"

then below code will work for you.

 func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
    
    if((webView.url?.scheme == "myapp") && webView.url?.host == "click"){
        print("user click the button")
     // Write the code to open Files folder of device.
    }
    decisionHandler(WKNavigationActionPolicy.allow)
    
}

I hope this would work for you.

  • Related