当应用在后台运行时收到Firebase消息时查找 [英] Findout when Firebase message recieved when app in background

查看:105
本文介绍了当应用在后台运行时收到Firebase消息时查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个标题也有相同的问题,但不幸的是,答案不正确,被接受了!!! 此处

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屋!

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