How to add customize HTTP headers in UIWebView request, my UIWebView is based on Cordova project?

前端 未结 5 1062
旧巷少年郎
旧巷少年郎 2021-02-06 15:22

My iOS UIWebView page is based on Cordova open source framework, and I want to add some customize http headers in its webview URL request, my solution is to add them in the foll

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 15:50

    I know its late but may help others for SWIFT 3.0

    let weburl = NSURL(string: "http://www.mywebsite.com")
        let request = NSMutableURLRequest(URL: weburl!)
        request.setValue("HEADER_VALUE", forHTTPHeaderField:"HEADER_NAME")
        myWebView.loadRequest(request)
    

提交回复
热议问题