WebKit User Agent
Requirements
- iOS 9.0+
- macOS 10.11+
Installation
See the subsections below for details about the different installation methods.
CocoaPods
- Prepare project for CocoaPods usage by CocoaPods – Install / Get Started
- Add pod to project’s profile
pod 'WebKitUserAgent'
- LETS ROCK! or install pod
cd {PATH_TO_PROJECT}
pod install
Swift Package Manager
- Go to project
File
→Add Packages...
- Search for library, using URL:
https://github.com/dmytriigolovanov/webkit-user-agent
- Set the
Dependency Rule
toUp to Next Major Version
Add Package
Using
Import library to needed swift file.
import WebKitUserAgent
Library provides 2 variants of usage.
- With prepared
WKWebView
.
example:
let webView = WKWebView(frame: .zero)
WKUserAgent.getUserAgent(webView: webView) { result in
switch result {
case .success(let userAgent):
// Get the User Agent
case .failure(let error):
// Handle error
}
}
- With
applicationName
String value (WKWebView
initializes in library).
Application name is additional part for User Agent, which will be added at the end of original WebView’s User Agent.
example:
let applicationName = "EXAMPLE/1.0.0"
WKUserAgent.getUserAgent(applicationName: applicationName) { result in
switch result {
case .success(let userAgent):
// Get the User Agent
case .failure(let error):
// Handle error
}
}
License
The contents of this repository are licensed under the
MIT License.