简体   繁体   中英

Ionic 3 app receives background notifications as expected from FCM web interface, but not with curl

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM