Android FCM Notification not working in background very first time

Viewed 113

Fcm Notification - onMessageReceived is not called in bacground very first time installed the application. The next time when I opened and closed the application it started working in background. I am testing in Redmi k20 pro android 10 version.

Any Suggestions

FCM Payload :

{
   "to":"dmYZxw7MkC9y58NIK86dp1xypDkCQKBmikujvVtAFJC....",
   "priority":"high",
   "data":{
      "NotifyId":"12",
      "title":"777",
      "body":"1234456756778787878"
   },
   "notification":{
      "NotifyId":"12",
      "title":"777",
      "body":"1234456756778787878"
   }
}

On Message Received :

@Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        RemoteMessage.Notification notification = remoteMessage.getNotification();
        Map<String, String> data = remoteMessage.getData();
        Log.d("FROM", remoteMessage.getFrom());
        sendNotification(notification, data);
    }
0 Answers
Related