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

前端 未结 2 909
耶瑟儿~
耶瑟儿~ 2020-12-21 00:06

Is it possible to show popup for firebase system notification (when app is in background) on the top of screen? I use setPriority(Notification.PRIORITY_MAX) for

2条回答
  •  梦毁少年i
    2020-12-21 00:42

    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

提交回复
热议问题