簡體   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