Faisal Shaikh Faisal Shaikh - 6 months ago 79
jQuery Question

Send Firebase push notification from JavaScript/jQuery

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() {
type : 'POST',
url : "https://fcm.googleapis.com/fcm/send",
headers : {
Authorization : 'key=' + 'xxxxxxxxxxxx-xxx-xxxxxxxxxxxxxx'
contentType : 'application/json',
data : {
"to": "videos",
"data": {
"message": "This is push for video!"
success : function(response) {
error : function(xhr, status, 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.


Try to call

JSON.stringify({"to": "videos", "data": {"message": "This is push for video!"}})

or add option dataType: 'json'