'window.webkit.messageHandlers is null on ios 15
window.webkit.messageHandlers gives null on ios 15, but when I set
config.limitsNavigationsToAppBoundDomains = true;
it works properly.
But I don't want to restrict my WkWebView to certain domains.
Code -
let config = WKWebViewConfiguration()
config.preferences.javaScriptEnabled = true
let userContentController = WKUserContentController()
userContentController.add(WKSMH, name: "print")
userContentController.add(WKSMH, name: "push-subscribe")
userContentController.add(WKSMH, name: "push-permission-request")
userContentController.add(WKSMH, name: "push-permission-state")
userContentController.add(WKSMH, name: "setUserAttribute")
config.userContentController = userContentController
if #available(iOS 14, *) {
config.limitsNavigationsToAppBoundDomains = true;
}
config.preferences.javaScriptCanOpenWindowsAutomatically = true
config.allowsInlineMediaPlayback = true
config.preferences.setValue(true, forKey: "standalone")
let webView = WKWebView(frame: calcWebviewFrame(webviewView: container, toolbarView: nil), configuration: config)
Is there any way to use messageHandlers other than using config.limitsNavigationsToAppBoundDomains = true
?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|