firebase云消息传递:setBackgroundMessageHandler不被调用 [英] firebase cloud messaging: setBackgroundMessageHandler not called

查看:296
本文介绍了firebase云消息传递:setBackgroundMessageHandler不被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用FCM原型化浏览器推送通知。我刚从快速入门复制了示例代码( https://github.com/火力/快速启动-JS /树/主/消息)。消息收到并显示应该是。但是当我尝试修改服务工作者(messaging.setBackgroundMessageHandler)中的消息时,没有任何反应。服务工作者被调用,如果我在该服务工作者中为推送通知实现了一个事件监听器,它会捕获该事件。但是setBackgroundMessageHandler方法永远不会被调用。
我在Chrome 54上试了这个。



任何想法,我需要做什么来定制服务工作者的消息? b

非常感谢!

解决方案

对于遇到同样问题的人来说,答案是: https://github.com/firebase/quickstart-js/issues/71

简短摘要:不要在您的json消息中包含notification元素。

I am prototyping browser push notifications with FCM. I just copied the example code from the quickstart (https://github.com/firebase/quickstart-js/tree/master/messaging). Messages are recieved and displayed as they should be. But when I try to modify the message in the Service Worker (messaging.setBackgroundMessageHandler) nothing happens. The service worker is called, and if I implement an event listener in that service worker for the push notifications, it catches the event. But the method setBackgroundMessageHandler is never called. I am trying this on Chrome 54.

Any ideas what I need to do to customize the message in the service worker?

Thank you very much!

解决方案

For anyone experiencing the same problem, here is the answer: https://github.com/firebase/quickstart-js/issues/71

short summary: do not include a "notification" element in your json message.

这篇关于firebase云消息传递:setBackgroundMessageHandler不被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆