参见英文答案 > How to handle notification when app in background in Firebase 22个
使用FCM的Android推送通知在后台应用程序时无法处理.通知栏中显示默认消息.
任何人都可以帮助我在后台应用程序时如何处理消息.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
}
最佳答案
如果始终从服务器接收有效负载作为“数据”,则始终会调用onMessageReceived().
原文链接:https://www.f2er.com/android/430106.html示例:
来自服务器的有效负载应如下所示:
{
"data":{
"id": 1,"missedRequests": 5
"addAnyDataHere": 123
},"to":"fhiT7evmZk8:APA91bFJq7Tkly4BtLRXdYvqHno2vHCRkzpJT8QZy0TlIGs......"
}
有关此问题的更多信息.请参考以下网址:Firebase onMessageReceived not called when app in background