繁体   English   中英

FCM for android:当应用程序处于后台时弹出系统通知

[英]FCM for android: popup system notification when app is in background

是否可以在屏幕顶部显示firebase系统通知的弹出窗口(当应用程序在后台时)? 我使用setPriority(Notification.PRIORITY_MAX)来显示来自前台的onMessageReceived通知。

我同时使用notificationdata字段,因此我无权访问前台收到的通知。 我已经尝试将priority设置为high并使用仅通知推送 - 没有任何帮助。

当使用仅data有效负载时,当应用程序处于后台时,只能在onMessageReceived处理消息。

在有效负载中同时使用notificationdata时,预期的行为是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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM