Posts

Post not yet marked as solved
3 Replies
I have similar problem with simple Safari Extension App.After Safari has been running for some time. On `send()` (button click in popover) 'SFSafariApplication.getAllWindows' stops working and completion handler is never fired. Console shows 'Error connecting back to host app: NSCocoaErrorDomain, code: 4099'.Edit: also 'SFSafariApplication.openWindow' not working after error Tested on Safari Technology Preview - Release 91 (Safari 13.1, WebKit 14609.1.3) MojaveSafariExtensionViewController.swift @IBAction func send(_ sender: Any) { self.count += 1 SFSafariApplication.getAllWindows { (windows) in for window in windows { window.getAllTabs { (tabs) in for tab in tabs { tab.getPagesWithCompletionHandler { (pages) in for page in pages ?? [] { page.dispatchMessageToScript(withName: "test", userInfo: ["count": self.count]) } } } } } } } @IBAction func open(_ sender: Any) { SFSafariApplication.openWindow(with: URL.init(string: "https://google.com")!) { (window) in NSLog("opened") } }script.jsdocument.addEventListener("DOMContentLoaded", function(event) { safari.self.addEventListener("message", function(event) { if (event.name === 'test') { console.log("Message from background received: ", event.message.count); } }); });