【发布时间】:2017-09-20 16:51:09
【问题描述】:
我正在尝试从一个简单的测试网页发送推送通知。我正在使用火力基地。这是我当前的代码:
function sendPushNotification() {
$.ajax({
type : 'POST',
url : "https://fcm.googleapis.com/fcm/send",
headers : {
Authorization : 'key=' + '<my_server_key>',
'Content-Type' : 'application/json'
},
contentType : 'application/json',
dataType: 'json',
data: JSON.stringify({"notification": {"body":"Test"}}),
success : function(response) {
console.log(response);
},
error : function(xhr, status, error) {
console.log(xhr);
}
});
}
我得到错误:
[Error] Failed to load resource: the server responded with a status of 400 (HTTP/2.0 400) (send, line 0)
我假设这是一个错误的请求。这样做的正确方法是什么?
【问题讨论】:
标签: javascript jquery firebase push-notification firebase-cloud-messaging