通过ajax错误将发布请求发送到Firebase云消息传递

时间:2018-08-12 07:04:46

标签: javascript jquery api firebase firebase-cloud-messaging

我想将远程推送通知发送到Firebase控制台中的ios应用,一切正常,我可以成功发送远程通知。但是我想在我的Web cms中使用ajax请求来发送通知,但它会产生401错误

Ajax请求:

InfoData = {
  "message":{
    "token" : "device token",
    "notification" : {
      "body" : "This is an FCM notification message!",
      "title" : "FCM Message",
      }
   }
}

$.ajax({
        type: "POST",
        url: 'https://fcm.googleapis.com/v1/projects/Project ID/messages:send',
        ContentType: 'application/json',
        headers : {

          Authorization : 'key=' + 'Web API Key'

      },
        data: InfoData,
        datatype: "html",
        success: function(result){
            console.log(result);
        }
    });

和控制台显示jquery-1.9.1.min.js:5 POST https://fcm.googleapis.com/v1/projects/sefrtasad-2e4d5/messages:send 401()

enter image description here

web cms语言是PHP

我错了什么? 有没有这样做的例子?

0 个答案:

没有答案