1

I understand I can set the user-agent via

NSUserDefaults.standardUserDefaults().registerDefaults(["UserAgent" : "ABC"])

However, is it possible to set the user agent, only when I am browsing a particular url, e.g. http://www.example.com, for other urls, I want to keep the user-agent remain unchanged.

Is it possible?

Ryan
  • 10,041
  • 27
  • 91
  • 156
  • You have to implement the delegate `shouldStartLoadWithRequest :` of `UIWebViewDelegate` and re-create a `NSMutableUrlRequest` from the original request and set new user-agent string base on the url of the request. Or, set the User-Agent to the `NSURLRequest` before load to UIWebView – Duyen-Hoa Nov 08 '16 at 07:45

0 Answers0