Monday, June 27, 2022
HomeiOS Developmentswift - window.webkit.messageHandlers is null on ios 15

swift – window.webkit.messageHandlers is null on ios 15


window.webkit.messageHandlers provides null on ios 15, however once I set
config.limitsNavigationsToAppBoundDomains = true; it really works correctly.

However I do not wish to prohibit my WkWebView to sure domains.

Code –


let config = WKWebViewConfiguration()
    config.preferences.javaScriptEnabled = true
    let userContentController = WKUserContentController()

    userContentController.add(WKSMH, title: "print")
    userContentController.add(WKSMH, title: "push-subscribe")
    userContentController.add(WKSMH, title: "push-permission-request")
    userContentController.add(WKSMH, title: "push-permission-state")
    userContentController.add(WKSMH, title: "setUserAttribute")
    config.userContentController = userContentController
    if #accessible(iOS 14, *) {
        config.limitsNavigationsToAppBoundDomains = true;
    }
    config.preferences.javaScriptCanOpenWindowsAutomatically = true
    config.allowsInlineMediaPlayback = true
    config.preferences.setValue(true, forKey: "standalone")
    
    let webView = WKWebView(body: calcWebviewFrame(webviewView: container, toolbarView: nil), configuration: config)

Is there any approach to make use of messageHandlers aside from utilizing config.limitsNavigationsToAppBoundDomains = true ?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments