当应用在后台运行时收到Firebase消息时查找 [英] Findout when Firebase message recieved when app in background
问题描述
我知道这个标题也有相同的问题,但不幸的是,答案不正确,被接受了!!! 此处
I know that there is the same question with this title but unfortunately it is not answered right and it is accepted!!! here
我想知道如何在应用程序处于后台时找出收到的FCM消息,以便在用户单击之前对收到的消息进行一些操作.但是当应用程序在后台onMessageReceived
时不会触发!
I want to know how I can find out a FCM message received when app is in background to do some action on message received before clicking by user. but when app is in background onMessageReceived
is not triggered!
我在Google上搜索了很多东西,却找不到一个好方法.
I googled so much and could not find a good way.
推荐答案
正如我在评论部分中提到的,当发送带有notification
消息有效负载的消息时,Android系统(通知托盘)将处理推送通知当您的应用程序在后台运行时.
As I've mentioned in the comments section, when sending a message with a notification
message payload the Android System (Notification Tray) will handle the push notification when your app is in background.
您应该使用仅data
的消息有效负载,以便始终由onMessageReceived()
处理.
You should use a data
-only message payload, so that it will always be handled by onMessageReceived()
.
有关详细信息,请参见在Android中处理消息文档
See the Handling Messages docs in Android for more details.
这篇关于当应用在后台运行时收到Firebase消息时查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!