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

前端 未结 5 1066
旧巷少年郎
旧巷少年郎 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 16:01

    Swift 5.2 Solution

    By making URLRequest & setValue

    @IBOutlet var wkWebView: WKWebView!
    let url = URL(string: "https://YouAreBest.com")
    var request = URLRequest(url: url!)
    request.setValue("1", forHTTPHeaderField:"userid")
    wkWebView.load(request)
    

提交回复
热议问题