Last active
June 27, 2017 12:31
-
-
Save starhoshi/d199f9f91604ee131782af173c8d0153 to your computer and use it in GitHub Desktop.
UIWebView で Custom UserAgent をセットする [Swift 3]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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