Package contains SDK to use camera torch from page loaded to WKWebView.
Add WebViewSDK using the Package manager in Xcode. Use the URL https://github.com/Transported-Labs/ios-webview-sdk
- Add import directive:
import WebViewSDK
- Init WebViewController object:
let sdkController = WebViewSDK.initWebViewController()
- Present WebViewController object and call it's .navigateTo() method:
// URL to your custom html-page with SDK script
let urlString = "https://www.google.com"
present(sdkController, animated: true) {
if let url = URL(string: urlString) {
do {
try sdkController.navigateTo(url: url)
} catch {
// Error handling when URL is not valid
sdkController.dismiss(animated: true)
print(error)
}
}
}