[英]FCM for android: popup system notification when app is in background
Is it possible to show popup for firebase system notification (when app is in background) on the top of screen? 是否可以在屏幕顶部显示firebase系统通知的弹出窗口(当应用程序在后台时)? I use
setPriority(Notification.PRIORITY_MAX)
for this to show notifications from onMessageReceived
in foreground. 我使用
setPriority(Notification.PRIORITY_MAX)
来显示来自前台的onMessageReceived
通知。
I use both notification
and data
fields, so I don't have access to received notification in foreground. 我同时使用
notification
和data
字段,因此我无权访问前台收到的通知。 I've tried setting priority
to high
and using notification-only pushes - nothing helps. 我已经尝试将
priority
设置为high
并使用仅通知推送 - 没有任何帮助。
It is only possible to handle the message in onMessageReceived
when your app is in background when using a data
only payload. 当使用仅
data
有效负载时,当应用程序处于后台时,只能在onMessageReceived
处理消息。
When using both notification
and data
in your payload, the expected behavior is that the Android System will handle the notification when the app is in background, regardless of what is the value of your priority
. 在有效负载中同时使用
notification
和data
时,预期的行为是Android系统将在应用程序处于后台时处理通知,而不管priority
的值是多少。
See the official docs on Handling Android Messages for more details. 有关更多详细信息 ,请参阅有关处理Android消息的官方文档。
If you sent data field only in notification, you can handle notification inside the below function 如果仅在通知中发送数据字段,则可以在以下功能中处理通知
@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());
}
}
Please note that don't include notification field in that request 请注意,该请求中不包含通知字段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.