I am using javascript and jquery to send a simple text push notification via parse.com using their rest api. This works :-
$.ajax({
type: 'POST',
headers: {
'X-Parse-Application-Id': "1234567890",
'X-Parse-REST-API-Key': "1234567890"
},
url: "https://api.parse.com/1/push",
data: '{"channel": "","type":"ios","expiration_interval":86400,"data":{"alert":"canned alert","badge" :0,"sound":""}}',
contentType: "application/json"
});
But this does not:-
var my_msg = "canned alert";
$.ajax({
type: 'POST',
headers: {
'X-Parse-Application-Id': "1234567890",
'X-Parse-REST-API-Key': "1234567890"
},
url: "https://api.parse.com/1/push",
data: '{"channel": "","type":"ios","expiration_interval":86400,"data":{"alert":my_msg,"badge" :0,"sound":""}}',
contentType: "application/json"
});
I cannot find a way to replace successfully send an alert with a variable instead of "canned alert". I am not an experienced programmer but even the parse.com tesch support could not explain why; can anyone suggest a solution please?