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

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

问题描述

我正在使用新的Firebase平台。我试图得到我的应用程序服务器发送的推送通知,并将其发送到我的iPhone。

我的安装程序工作在手动将消息发送到网站上的Firebase通知区域,但是当我尝试使用POST向 https://fcm.googleapis.com/fcm/send 我没有收到任何消息传递到设备。



我发送以下内容(使用auth头文件)

  {通知:{
title:葡萄牙对丹麦,
text:5至1
},
至:< ;注册令牌>

$ / code $ / pre

我得到了一个来自POST的200响应。 / b>

  {
multicast_id:5511974093763495964,
成功:1,
失败:0,
canonical_ids:0,
results:[
{
message_id:0:1463685441784359%3ad254b53ad254b5
} $ b如果我尝试直接通过Firebase网站发送到此设备,则可以使用以下功能:[b]
}

它的工作原理,但上面的表单不是。不知道该从哪里出发!

解决方案

在iOS中,优先级

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


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

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

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

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!

解决方案

On iOS the priority field seems mandatory.

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

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

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