Skip to content
Guest Big Announcement

wkwebkit is not downloading files from url swift 3

Featured Replies

im new in programming and have a project with wkwebkit written is swift 3 that load page with an ipa file in a url but the wkwebkit cant install the app unlike the uiwebview this is the code

 

import UIKit

import WebKit


var WEB : WKWebView!


class FirstViewController: UIViewController , WKNavigationDelegate   {

    override func viewDidLoad() {
        super.viewDidLoad()

        let myBlog = "https://www.pgyer.com/EcCK"
        let url = NSURL(string: myBlog)
        let request = URLRequest(url: url! as URL)



        // init and load request in webview.
        WEB = WKWebView(frame: self.view.frame)
        WEB.navigationDelegate = self
        WEB.load(request)
        self.view.addSubview(WEB)
        self.view.sendSubview(toBack: WEB)


    }

    override var prefersStatusBarHidden: Bool {
        return true
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
        if let urlResponse = navigationResponse.response as? HTTPURLResponse,
            let url = urlResponse.url,
            let allHeaderFields = urlResponse.allHeaderFields as? [String : String] {
            let cookies = HTTPCookie.cookies(withResponseHeaderFields: allHeaderFields, for: url)
            HTTPCookieStorage.shared.setCookies(cookies , for: urlResponse.url!, mainDocumentURL: nil)
            decisionHandler(.allow)
        }
    }


}

Create an account or sign in to comment

Featured Content

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.