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

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

问题描述

我正在从Parse迁移到Firebase,并面临我们的iOS应用程序出现问题。
Firebase API不会将推送通知发送到ios应用程序。
这就是发送到 https://fcm.googleapis.com/fcm/send

  {
to:< registration token>,
priority :
data:{
customId:< my custom id>,
badge:1,
sound: cheering.caf,
alert:新数据可用
}
}

服务器正在返回成功

$ p
multicast_id:6917019914327105115,
success:1,
failure:0,
canonical_ids:0,
results:[{message_id:0:1468961966677585%f0f84693f9fd7ecd





但是没有发送
如果我发送使用Firebase Dashboard进行推送,即使我直接使用Token,推送也是可用的。



我看到另一个开发人员抱怨另一个Stackoverflow问题
<一个href =https://stackoverflow.com/questions/37332415/cant-send-push-notifications-using-the-server-api>无法使用服务器API发送推送通知



我尝试了添加priority:high的解决方案,但没有解决问题。但它给了我一个线索:他们也使用dev / sandbox推送证书。

我的怀疑是仪表板可以使用ios开发证书,但API可以不。这个问题只发生在iOS设备上,因为Android应用程序正在通过API推送。



是否有人能够使用API​​和开发证书发送推送?

解决方案

我已经与Firebase支持部门联系,并能够找出问题所在。 $ b

我的推送有效内容缺少通知对象

  {
to:< registration
优先级:高,
通知:{
title:您的标题,
text:您的文本
data:{
customId:< my custom id>,
badge: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

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

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