Vlad Constantinescu
Vlad Constantinescu

Reputation: 101

Extension keyboard not working with IOS 16

I have a basic keyboard extension that was working with IOS 15 before updating my phone to IOS 16.1 .

The keyboard has a WKWebView that renders a basic html page with some text in it (code sample bellow)

When running on the simulator with IOS 16 everything loads perfectly.

The problem appears when I'm trying to run the application on an actual device, there I am stuck in a white screen (WKWebView loads, but the content is not loading) and a lot of errors ( log : https://pastebin.com/jC62Mwgd ). NOTE: the log was taken from a test run of the keyboard in 'Notes' application

Keyboard extension code :

    func makeViewConfiguration() -> WKWebViewConfiguration
    {
        let configuration = WKWebViewConfiguration()
        let dropSharedWorkersScript = WKUserScript(source: "delete window.SharedWorker;", injectionTime: WKUserScriptInjectionTime.atDocumentStart, forMainFrameOnly: false)
        configuration.userContentController.addUserScript(dropSharedWorkersScript)
        return configuration
    }

 override func viewDidLoad() {
        super.viewDidLoad()
        popup = UIView()
        popup.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        
        webView = WKWebView(frame: CGRect(x:100, y:100, width:100, height:350), configuration: makeViewConfiguration())
        webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        webView.frame = CGRect(origin: CGPoint.zero, size: popup.frame.size)
        webView.backgroundColor = UIColor.white
        webView.uiDelegate = self

        let contentController = webView.configuration.userContentController
        contentController.add(self, name: "toggleMessageHandler")

        popup.addSubview(webView)

        
        webView.loadHTMLString("<html><body><p>Hello!</p></body></html>", baseURL: nil)
        
        popup.backgroundColor = UIColor.cyan;
       
        self.view.addSubview(popup)
       
    }

Already tried but nothing changed:

Upvotes: 1

Views: 250

Answers (0)

Related Questions