반응형
let webConfiguration = WKWebViewConfiguration()
webConfiguration.applicationNameForUserAgent = "customize User-Agent"
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
Output : Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7
(KHTML, like Gecko) customize User-Agent
let webView = WKWebView()
webView.evaluateJavaScript("navigator.userAgent") { (userAgent, error) in
if let ua = userAgent {
print("default WebView User-Agent > \(ua)")
}
// User-Agent에 '(my test)' 추가할 경우
webView.customUserAgent = "\(ua) (my test)"
}
UserDefaults.standard.register(defaults: ["UserAgent": userAgentValue])
Output : Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7
(KHTML, like Gecko) customize User-Agent (my test)
반응형
'개발 > iOS' 카테고리의 다른 글
SEED 블록암호 알고리즘 CBC (Cipher Block Chaining) 예제 (1/2) (0) | 2020.05.28 |
---|---|
Array <-> Data 변환 (0) | 2020.05.26 |
RSA 암호화 / 복호화 (0) | 2020.05.25 |
Base64 인코딩/디코딩 (0) | 2020.05.25 |
Bitbucket Carthage 사용 (0) | 2020.05.19 |