Reputation: 21
I have included FCM from Ionic Native, and I can receive notifications in the background and the foreground when I send a message from the FCM web interface. It works as expected. However, when I curl
the request it only works in when the app is in the foreground. Does anyone know why this would be? I didn't see anything http protocol docs.
Here is the request that I am sending.
curl -H "Content-type: application/json" -H "Authorization:key=<fcm server key>" -X POST -d '{ "data": { "title": "wow", "msg": "hello world"},"to":"<fcm token>"}' https://fcm.googleapis.com/fcm/send
I also tried to mimic the network traffic from the FCM web interface to see if it had to do with the payload fields, but still no luck.
Upvotes: 1
Views: 438
Reputation: 21
I found what I was looking for. In order for the notification to show up when the app is closed, or running in the background, the notification
object must exist in the payload. For me, it had to have either a title or a body field as well.
Upvotes: 1