无法使用服务器 API 发送推送通知 [英] Can't send push notifications using the server API

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

问题描述

我正在使用新的 Firebase 平台.我正在尝试获取我的应用服务器发送的推送通知并发送到我的 iPhone.

Im using the new Firebase platform. Am trying to get a push notification sent by my app server and delivered to my iPhone.

我的设置工作正常,我在网站上的 Firebase 通知区域手动发送消息,但是当我尝试通过 POST 将消息发送到 https://fcm.googleapis.com/fcm/send 我没有收到任何消息传送到设备.

I have the setup working where I manually send the message with the Firebase notifications area on the website, but when I try and send the message with a POST to https://fcm.googleapis.com/fcm/send I get no message being delivered to the device.

我正在发送以下内容(带有身份验证标头)

I'm sending the following (with auth headers)

{ "notification": {
    "title": "Portugal vs. Denmark",
    "text": "5 to 1"
  },
  "to" : "<registration token>"
  }

我收到来自 POST 的 200 响应,正文如下:

I'm getting a 200 response from the POST with the following body:

    {
  "multicast_id": 5511974093763495964,
  "success": 1,
  "failure": 0,
  "canonical_ids": 0,
  "results": [
    {
      "message_id": "0:1463685441784359%3ad254b53ad254b5"
    }
  ]
}

如果我尝试通过 Firebase 网站直接发送到此设备,它可以工作,但上面的表单帖子没有.不知道从这里去哪里!

If I try and send to this device directly through the Firebase website it works, but the above form post doesn't. No idea where to go from here!

推荐答案

在 iOS 上,priority 字段似乎是强制性的.

On iOS the priority field seems mandatory.

{   
  "to": "cHPpZ_s14EA:APA91bG56znW...",
  "priority": "high",
  "notification" : {
    "body" : "hello!",
    "title": "afruz",
    "sound": "default"
  }
} 

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

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