![](/img/trans.png)
[英]Android FCM: FCM display(notification) message loggin when app is in background
[英]FCM for android: popup system notification when app is in background
是否可以在屏幕顶部显示firebase系统通知的弹出窗口(当应用程序在后台时)? 我使用setPriority(Notification.PRIORITY_MAX)
来显示来自前台的onMessageReceived
通知。
我同时使用notification
和data
字段,因此我无权访问前台收到的通知。 我已经尝试将priority
设置为high
并使用仅通知推送 - 没有任何帮助。
当使用仅data
有效负载时,当应用程序处于后台时,只能在onMessageReceived
处理消息。
在有效负载中同时使用notification
和data
时,预期的行为是Android系统将在应用程序处于后台时处理通知,而不管priority
的值是多少。
有关更多详细信息 ,请参阅有关处理Android消息的官方文档。
如果仅在通知中发送数据字段,则可以在以下功能中处理通知
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " +remoteMessage.getNotification().getBody());
}
}
请注意,该请求中不包含通知字段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.