简体   繁体   English

Ionic 3 应用程序按预期从 FCM Web 界面接收后台通知,但不是 curl

[英]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.

相关问题 Android FCM在从后台删除应用时未收到通知 - Android FCM not receiving notifications when app is removed from background 使用FCM的Ionic 2推送通知 - Ionic 2 Push Notifications with FCM 当应用程序处于后台状态时,FCM多个推送通知无法正常工作 - FCM Multiple push notifications not working properly when app in background state 当应用程序有后台处理程序时,在 Flutter 中未收到 FCM 通知 - FCM notifications not received in Flutter when there is a background handler for the app 当应用程序处于前台或后台时如何使用 FCM 处理通知 - How to handle notifications with FCM when app is in either foreground or background 如果用户清除通知并且应用程序在后台android中,则处理FCM数据消息 - Handling FCM data messages if user clears notifications and app is in background android FCM 推送通知仅在应用程序处于后台时显示 - FCM Push Notifications are only displayed when app is in background Ionic / Cordova应用程序不会在后台接收推送通知 - Ionic/Cordova app doesn't receives push notification in the background FCM - 当应用被杀/在后台时,应用会收到通知但不播放通知声音 - FCM - When app is killed/in background, app receives notification but does not play the notification sound 从后台安排本地通知(Ionic + ngCordova) - Scheduling local notifications from the background (Ionic + ngCordova)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM