当应用在后台运行时,是否可能在屏幕顶部显示 Firebase 系统通知的弹出窗口?我使用 setPriority(Notification.PRIORITY_MAX)
显示来自 onMessageReceived
的前台通知。
我同时使用 notification
和 data
字段,因此无法在前台访问收到的通知。我尝试过将 priority
设置为 high
并使用仅限通知的推送 - 都没有帮助。
当应用在后台运行时,是否可能在屏幕顶部显示 Firebase 系统通知的弹出窗口?我使用 setPriority(Notification.PRIORITY_MAX)
显示来自 onMessageReceived
的前台通知。
我同时使用 notification
和 data
字段,因此无法在前台访问收到的通知。我尝试过将 priority
设置为 high
并使用仅限通知的推送 - 都没有帮助。
data
类型的负载时,当您的应用程序在后台运行时,才能在 onMessageReceived
中处理消息。notification
和 data
,则无论您的 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());
}
}