Reputation: 4138
I am trying to send Firebase push notification from my html page to Android app. I am refering this SO answer to implement it. Here is my code:
function post() {
$.ajax({
type : 'POST',
url : "https://fcm.googleapis.com/fcm/send",
headers : {
Authorization : 'key=' + 'xxxxxxxxxxxx-xxx-xxxxxxxxxxxxxx'
},
contentType : 'application/json',
data : {
"to": "/topics/videos",
"data": {
"message": "This is push for video!"
}
},
success : function(response) {
console.log(response);
},
error : function(xhr, status, error) {
console.log(xhr.error);
}
});
Currently, I am facing issue that in response of POST request
I am getting following error:
JSON_PARSING_ERROR: Unexpected character (t) at position 0.
Upvotes: 0
Views: 8072
Reputation: 66488
Try to call
JSON.stringify({"to": "videos", "data": {"message": "This is push for video!"}})
or add option dataType: 'json'
Upvotes: 1