使用 API 时,Firebase API 不发送推送通知
Firebase API is not sending push notifications when using the API
我正在从 Parse 迁移到 Firebase,但我们的 ios 应用遇到了问题。
Firebase API 不会向 ios 应用程序发送推送通知。
这是我发送给 https://fcm.googleapis.com/fcm/send
的内容
{
"to: "<registration token>",
"priority": "high",
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
并且服务器正在返回成功
{
"multicast_id":6917019914327105115,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]
}
但是推送没有送达。
如果我使用 Firebase 仪表板发送推送,推送就会被传送,即使我直接使用令牌进行定位也是如此。
我看到另一个开发人员在另一个 Whosebug 问题中抱怨
我尝试了他们添加 "priority" 的解决方案:"high",但没有解决问题。但这给了我一个线索:他们也在使用 dev/sandbox 推送证书。
我怀疑Dashboard可以使用ios开发证书,但是API不可以。该问题只发生在 ios 设备上,因为 android 应用程序正在通过 API.
获取推送
有人可以使用 API 和开发证书发送推送吗?
我与 Firebase 支持人员联系并能够找出问题所在
我的推送负载缺少通知对象
{
"to": "<registration token>",
"priority": "high",
"notification": {
"title": "Your Title",
"text": "Your Text"
}
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
希望对其他人有所帮助
您使用 Firebase API 发送到 https://fcm.googleapis.com/fcm/send 的对象应该如下所示:
{
"notification":{
"title":"Notification title", //Any value
"body":"Notification body", //Any value
"sound":"default", //If you want notification sound
"click_action":"<activity_name>", //Must be present for Android
"icon":"fcm_push_icon" //White icon Android resource
},
"data":{
"param1":"value1", //Any data to be retrieved in the notification callback
"param2":"value2"
},
"to":"/topics/topicExample", //Topic or single device
"priority":"high", //If not set, notification won't be delivered on completely closed iOS app
"restricted_package_name":"" //Optional. Set for application filtering
}
如果您的问题已经解决,请不要忘记标记它。
我正在从 Parse 迁移到 Firebase,但我们的 ios 应用遇到了问题。 Firebase API 不会向 ios 应用程序发送推送通知。 这是我发送给 https://fcm.googleapis.com/fcm/send
的内容{
"to: "<registration token>",
"priority": "high",
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
并且服务器正在返回成功
{
"multicast_id":6917019914327105115,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]
}
但是推送没有送达。 如果我使用 Firebase 仪表板发送推送,推送就会被传送,即使我直接使用令牌进行定位也是如此。
我看到另一个开发人员在另一个 Whosebug 问题中抱怨
我尝试了他们添加 "priority" 的解决方案:"high",但没有解决问题。但这给了我一个线索:他们也在使用 dev/sandbox 推送证书。
我怀疑Dashboard可以使用ios开发证书,但是API不可以。该问题只发生在 ios 设备上,因为 android 应用程序正在通过 API.
获取推送有人可以使用 API 和开发证书发送推送吗?
我与 Firebase 支持人员联系并能够找出问题所在
我的推送负载缺少通知对象
{
"to": "<registration token>",
"priority": "high",
"notification": {
"title": "Your Title",
"text": "Your Text"
}
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
希望对其他人有所帮助
您使用 Firebase API 发送到 https://fcm.googleapis.com/fcm/send 的对象应该如下所示:
{
"notification":{
"title":"Notification title", //Any value
"body":"Notification body", //Any value
"sound":"default", //If you want notification sound
"click_action":"<activity_name>", //Must be present for Android
"icon":"fcm_push_icon" //White icon Android resource
},
"data":{
"param1":"value1", //Any data to be retrieved in the notification callback
"param2":"value2"
},
"to":"/topics/topicExample", //Topic or single device
"priority":"high", //If not set, notification won't be delivered on completely closed iOS app
"restricted_package_name":"" //Optional. Set for application filtering
}
如果您的问题已经解决,请不要忘记标记它。