代理/覆盖 ServiceWorkerRegistration 函数的方法

问题描述

我正在尝试代理 ScreenManager: MainScreen: GroupScreen: <DialogContent>: textfield: textfield orientation: "vertical" spacing: "12dp" size_hint_y: None height: "120dp" MDTextField: id: textfield hint_text: "Group name" MDFlatButton: id: btn1 text: "Done" text_color: self.theme_cls.primary_color on_release: root.get_screen['main'].close_dialog() <MainScreen>: name: 'main' mdlist: mdlist FloatLayout: size_hint: 1,0.89 ScrollView: MDList: id: mdlist MDFloatingActionButton: pos_hint: {'right': 0.95,'y': 0.05} icon: "android" theme_text_color: "Custom" text_color: app.theme_cls.primary_color on_release: root.show_dialog() <GroupScreen>: name: 'group' MDLabel: text: 'Welcome' halign: 'center' MDRectangleFlatButton: text: 'Back' pos_hint: {'center_x': 0.5,'center_y': 0.3} on_release: root.manager.current = 'main' 对象的 showNotification 方法。这是我现在的做法:

ServiceWorkerRegistration

调用 function swNotificationCallback(title,opt) { console.log("title",title); console.log("options",opt); return true } function createSWHandler(original) { return (title,opt) => { if (swNotificationCallback(title,opt)) {return original(title,opt)} } } navigator.serviceWorker.getRegistrations().then(val => val.forEach(sw => { if (!sw._showNotification) { // backup the old just in case sw._showNotification = sw.showNotification; sw.showNotification = createSWHandler(sw.showNotification); } })); 正确记录所有内容,但未显示通知并抛出此错误: sw.showNotification

有什么办法可以解决这个问题吗?我认为可以使用代理,但我不确定如何重新分配注册的服务工作者。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)