且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[Firebase Messaging]:当应用程序在后台运行时,不会调用Background Message Handler方法吗?

更新时间:2022-12-27 12:24:31

已经很晚了,但我还是会回应其他人的帮助.

It's late but still I'll respond for others to be helpful.

这里的问题与处理无关,而与您从Firebase控制台发送的消息类型有关.仅当消息是数据消息或带有数据有效负载的通知消息时,才会调用 onBackgroundMessage callBack.

The issue here isn't with the handling but with type of message you are sending from the Firebase console. onBackgroundMessage callBack is called only if the message is a data message or a notification message with a data payload.

并确保您的消息中还添加了 click_action:'FLUTTER_NOTIFICATION_CLICK'.

And make sure your message also have click_action: 'FLUTTER_NOTIFICATION_CLICK' added.

从Firebase控制台生成消息也存在一些问题,因此请尝试直接从服务器生成消息.有关更多详细信息,请查看此线程.

And there as well is some issue with generating messages from Firebase console, so try to generate messages directly from your server. For more details please checkout this thread.