![](/img/trans.png)
[英]Android FCM: FCM display(notification) message loggin when app is in background
[英]FCM for android: popup system notification when app is in background
是否可以在屏幕頂部顯示firebase系統通知的彈出窗口(當應用程序在后台時)? 我使用setPriority(Notification.PRIORITY_MAX)
來顯示來自前台的onMessageReceived
通知。
我同時使用notification
和data
字段,因此我無權訪問前台收到的通知。 我已經嘗試將priority
設置為high
並使用僅通知推送 - 沒有任何幫助。
當使用僅data
有效負載時,當應用程序處於后台時,只能在onMessageReceived
處理消息。
在有效負載中同時使用notification
和data
時,預期的行為是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.