Fel*_*ira 4 push-notification ios firebase firebase-cloud-messaging
我正在从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"
}
}
Run Code Online (Sandbox Code Playgroud)
服务器正在恢复成功
{
"multicast_id":6917019914327105115,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]
}
Run Code Online (Sandbox Code Playgroud)
但推动没有实现.如果我使用Firebase控制台发送推送,即使我直接使用令牌定位,也会推送推送.
我看到另一个开发人员抱怨另一个Stackoverflow问题 无法使用服务器API发送推送通知
我尝试了添加"优先级"的解决方案:"高",它没有解决问题.但它给了我一个线索:他们也在使用dev/sandbox推送证书.
我怀疑仪表板可以使用ios开发证书,但API不能.问题只发生在ios设备上,因为Android应用程序正在通过API推送.
是否有人能够使用API和开发证书发送推送?
Fel*_*ira 13
我与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"
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能帮到别人
小智 7
您使用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
}
Run Code Online (Sandbox Code Playgroud)
如果您的问题已经解决,请不要忘记将其标记为.
| 归档时间: |
|
| 查看次数: |
3935 次 |
| 最近记录: |