Firebase API 在使用 API 时不发送推送通知 [英] Firebase API is not sending push notifications when using the API

查看:19
本文介绍了Firebase API 在使用 API 时不发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Parse 迁移到 Firebase,但我们的 ios 应用遇到了问题.Firebase API 不会向 ios 应用发送推送通知.这是我发送给 https://fcm.googleapis.com/fcm/send 的内容>

<代码>{"to: "<注册令牌>",优先级":高",数据": {"customId": "<我的自定义 ID>",徽章":1,"sound": "cheering.caf","alert": "新数据可用"}}

服务器返回成功

<代码>{multicast_id":6917019914327105115,成功":1,失败":0,"canonical_ids":0,"结果":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]}

但是推送没有发送.如果我使用 Firebase 仪表板发送推送,即使我直接使用令牌进行定位,也会发送推送.

我看到另一位开发人员在另一个 Stackoverflow 问题中抱怨无法使用服务器 API 发送推送通知>

我尝试了他们添加 "priority": "high" 的解决方案,但没有解决问题.但它给了我一个线索:他们也在使用开发/沙盒推送证书.

我怀疑是Dashboard可以使用ios开发证书,但是API不行.问题仅发生在 ios 设备上,因为 android 应用程序通过 API 获取推送.

有人可以使用 API 和开发证书发送推送吗?

解决方案

Firebase 支持人员与我联系并找出问题所在

我的推送负载缺少通知对象

<代码>{"to": "<注册令牌>",优先级":高",通知": {"title": "你的标题","text": "你的文本"}数据": {"customId": "<我的自定义 ID>",徽章":1,"sound": "cheering.caf","alert": "新数据可用"}}

希望能帮到别人

I'm migrating from Parse to Firebase and facing a problem with our ios app. The Firebase API does not send push notifications to the ios app. This is what im sending to 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"
  }
}

And the server is returning success

{
    "multicast_id":6917019914327105115,
    "success":1,
    "failure":0,
    "canonical_ids":0,
    "results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]
}

But the push is not delivered. If I sent the push using the Firebase Dashboard, the pushes are delivered, even if I targeting directly with the Token.

I saw another developer complaining in another Stackoverflow question Can't send push notifications using the server API

I tried their solution of adding the "priority": "high", it did not fixed the issue. But it gave me a clue: They are also using the dev/sandbox push certificate.

My suspicion is that the Dashboard can use the ios Development certificate, but the API can not. The problem only happen on the ios device, since the android app are getting the pushes through API.

Is anyone able to send pushes using the API and the development certificate?

解决方案

I got contacted by Firebase support and was able to find out what is wrong

My push payload was missing a notification object

{ 
 "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"
  }
}

I hope that helps someone else

这篇关于Firebase API 在使用 API 时不发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆