Skip to content

Instantly share code, notes, and snippets.

@starhoshi
Last active June 27, 2017 12:31
Show Gist options
  • Save starhoshi/d199f9f91604ee131782af173c8d0153 to your computer and use it in GitHub Desktop.
Save starhoshi/d199f9f91604ee131782af173c8d0153 to your computer and use it in GitHub Desktop.
UIWebView で Custom UserAgent をセットする [Swift 3]
import UIKit
extension UIWebView {
func setCustomUserAgent() {
let classiSuffix = Constants.userAgent
let originalUserAgent = stringByEvaluatingJavaScript(from: "navigator.userAgent")!
let customUserAgent = originalUserAgent + "+CustomUA"
UserDefaults.standard.register(defaults: ["UserAgent": customUserAgent])
print("new userAgent: \(pbUserAgent)")
}
}
UIWebView().setCustomUserAgent()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment