FCM notification title remains "FCM Message"

Issue

I’m trying to use the Firebase Cloud Messaging. I send the notifications from a Node.js server to my apps that are registered to the notification system.

My problem is that on Android 5.1 the notification is “FCM Message” even if I setted the title attribute in the nofitification json. It works fine in Android 6.0. I tried to reboot my device as well.

enter image description here

And this is the code I use to send the notification:

function sendNotificationToUser(userToken, message, onSuccess) {
  request({
    url: 'https://fcm.googleapis.com/fcm/send',
    method: 'POST',
    headers: {
      'Content-Type' :' application/json',
      'Authorization': 'key='+API_KEY
    },
    body: JSON.stringify({
      notification: {
        "title": 'My App Name',
        "body": message,
        "sound": 'default'
      },
      to : userToken
    })
  }, function(error, response, body) {
    if (error) { console.error(error); }
    else if (response.statusCode >= 400) { 
      console.error('HTTP Error: '+response.statusCode+' - '+response.statusMessage); 
    }
    else {
      onSuccess();
    }
  });
}

As you can see the notification title I send is “My App Name” but on device it shows “FCM Message”.

What do I have to do?!

Solution

I found that it is a problem related to onMessageReceived callback.

enter image description here

As you can see on the receive a FCM guide

Answered By – Jackie Degl'Innocenti

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *