static get permission() { window.webkit.messageHandlers.notifyRequest.postMessage(true); return "granted"; } static requestPermission (callback) { callback("granted"); window.webkit.messageHandlers.notifyRequest.postMessage(true); } constructor (title, options) { window.webkit.messageHandlers.notify.postMessage({ title: title, body: options.body }); } } window.Notification = NotificationOverride; """ let userScript2 = WKUserScript(source: script2, injectionTime: .atDocumentStart, forMainFrameOnly: true) webView.configuration.userContentController.addUserScript(userScript2) webView.configuration.userContentController.add(self, name: "notify") webView.configuration.userContentController.add(self, name: "notifyRequest")