我試圖通過Firebase向我的設備發送消息。但是我得到了錯誤。我在先進的REST客戶端上成功測試了它。這是來自其他客戶端的消息通過ajax向firebase雲消息發送請求?
Content-Type: application/json
Authorization: key=MY-KEY
Content-Length: 106
POST /fcm/send HTTP/1.1
HOST: fcm.googleapis.com
content-type: application/json
authorization: key=MY-KEY
content-length: 106
{
"to":"/topics/Self_Taught"
"notification":
{
"body":"Hello"
}
}
基於此,我提出了我的JavaScript代碼。不要擔心油條,這是其他圖書館,它正常工作。
$.ajax({
url: "https://fcm.googleapis.com/fcm/send",
type: "POST",
contentType: "application/json",
authorization: "key=MY-KEY",
data: {
"to": "/topics/Self_Taught",
"notification": {
"body": message
}
},
success: function (result) {
$.gritter.add({
title: "",
text: result.message_id,
class_name: 'gritter-success'
});
},
error: function (result) {
$.gritter.add({
title: "",
text: result.error,
class_name: 'gritter-error'
});
}
});
而這就是我從result.error
function() {
if (l) {
var t = l.length;
(function i(t) {
x.each(t, function (t, n) {
var r = x.type(n);
"function" === r ? e.unique && p.has(n) || l.push(n) : n && n.length && "string" !== r && i(n)
})
})
(arguments), n ? o = l.length : r && (s = t, c(r))
}
return this
}
我回來之後改變「通知」此鏈接到「數據」和「身體」到「信息」。但我得到了同樣的錯誤。 https://firebase.google.com/docs/cloud-messaging/android/topic-messaging#http_post_request
哪裏是我的錯? :(謝謝
你能顯示哪些FCM報告錯誤? –
@KanishkDudeja它是什麼? –