'Flutter firebase push notifications am not able to catch the payload. They were all data messages, not notification

Receiving notification only when sending both "notification" payload and "data" payload. They were all data messages, not notification. Below case is not working.

{
"from": “12345678”,
"data": {
"gcm.notification.message": "Title of your Notificationn”,
"gcm.notification.subject": "Body of your Notification"
}
}.



  FirebaseMessaging.instance
    .getInitialMessage()
    .then((RemoteMessage? message) {
  if (message != null && message.data != null) {
    print('AppPush ===================getInitialMessage : ${message.data}');
    _serialiseAndNavigate(message.data);
  }
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
  if (message != null && message.data != null) {
    print('AppPush ===================onMessage : ${message.data}');
    _serialiseAndNavigate(message.data);
  }
});

How can I resolve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source