How can I get "User-Agent" UIWebView in Swift3
I need to change the useragent for some requests and so I either need to get it first or add something to it. What's the best way to do this? Do you need to use webview to do this, or are there other ways?
what i am trying:
var userAgent = ""
if UIWebView().stringByEvaluatingJavaScript(from: "navigator.userAgent") != nil{
userAgent = userAgent + " Custom-Agent"
}
print(userAgent)
UserDefaults.standard.register(defaults: ["UserAgent" : userAgent])
+3
source to share