[英]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.我已经包含了来自 Ionic Native 的 FCM,当我从 FCM Web 界面发送消息时,我可以在后台和前台接收通知。 It works as expected.
它按预期工作。 However, when I
curl
the request it only works in when the app is in the foreground.但是,当我
curl
请求时,它仅在应用程序处于前台时才有效。 Does anyone know why this would be?有谁知道为什么会这样? I didn't see anything http protocol docs .
我没有看到任何http 协议文档。
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.我还尝试模拟来自 FCM Web 界面的网络流量,看看它是否与有效载荷字段有关,但仍然没有运气。
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.为了在应用程序关闭或在后台运行时显示通知,
notification
对象必须存在于有效负载中。 For me, it had to have either a title or a body field as well.对我来说,它也必须有标题或正文字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.