rc1911 rc1911 - 4 months ago 47
Node.js Question

FCM Notifications Not Displaying When App Is Terminated iOS

I'm developing an app that uses Firebase Cloud Messaging for notifications, I've setup my app to receive the notifications, and have also written a basic node.js server to handle sending the notifications automatically.

Everything is working fine except I can't seem to receive the notifications sent from my server once the app is terminated. Notifications sent from the FCM console, however, display fine whether the app is running in the background or not. I've tried adding a number of fields to my JSON data in the server message (priority, content_available, etc.) but nothing seems to work. Here is my json data that comprises the notification:

"notification" : {
"title" : "New message",
"body" : "You have a new message!",
"sound" : "default",
//"badge" : "1",
//"content_available" : true,
"priority" : "high"
},
"to" : recipientID,


Is there a field here that I am missing?

Thanks in advance!

Answer

Seems like your priority field is at the wrong level. Priority should be a sibling of "to" and "notification". Eg:

"notification" : {
  "title" : "New message",
  "body" : "You have a new message!",
  "sound" : "default"
},
"priority" : "high",
"to" : recipientID,
Comments