使用 API 时 Firebase API 不发送推送通知

Firebase API is not sending push notifications when using the API(使用 API 时 Firebase API 不发送推送通知)
本文介绍了使用 API 时 Firebase API 不发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

服务器返回成功

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

但是推送没有送达.如果我使用 Firebase 仪表板发送推送,即使我直接使用 Token 定位,推送也会被传递.

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.

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

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

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

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.

我怀疑 Dashboard 可以使用 ios Development 证书,但 API 不能.该问题仅发生在 ios 设备上,因为 android 应用正在通过 API 获取推送.

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.

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

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

推荐答案

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

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

希望对其他人有所帮助

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)