I am attempting to send a push notification from a simple test webpage. I am using firebase. This is my current code:
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);
}
});
}
I get the error:
[Error] Failed to load resource: the server responded with a status of 400 (HTTP/2.0 400) (send, line 0)
Which I am assuming is a bad request. What is the correct way to do this?