简体   繁体   English

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

[英]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. 我同时使用notificationdata字段,因此我无权访问前台收到的通知。 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 . 在有效负载中同时使用notificationdata时,预期的行为是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.

相关问题 Android FCM:当应用程序在后台时 FCM 显示(通知)消息登录 - Android FCM: FCM display(notification) message loggin when app is in background 应用程序在后台时无法获取fcm通知 - Unable to get fcm notification when app is in background 当应用程序在前台而不是后台时,FCM通知,通知单击 - FCM notification, notification click when app is in foreground not background 当应用程序处于后台/杀死 Android 时,无法从 FCM 通知中提取数据 - Unable to extract data from FCM notification when app is in background/kill in Android 当应用程序在后台运行时,FCM的意图不起作用(android) - intent with FCM not working when app is in background(android) FCM后台通知问题android - FCM background notification issue android 当应用程序在后台或在 FCM 服务中被杀死时如何处理多个通知 - How to handle multiple notification when app in background or killed in FCM services 如何删除应用程序处于后台时出现的单个 fcm 通知? - how to delete single fcm notification which comes when app is background? 在前台在后台收到FCM通知时应用崩溃 - App Crashes when receiving FCM Notification on Foreground works on Background 当应用程序处于后台时,我的FCM通知不会扩展 - My FCM notification does not expand when the app is in background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM