Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

I have the following, which i took from the docs http://docs.appery.io/documentation/b.... But I am unable to make it work, as it keeps giving me an error in console.

{"payload":{"message" : You have a question in your area, "badge" : 0}, [ "filter" : {"lc" : "Cotterell"}]}

Could someone check this syntax:

codedata: JSON.stringify('{"payload":{"message" : '+message+', "badge" : 0}, [ "filter" : {"lc" : "'+ sname +'"}]}');/code

Thanks.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Push Notification API Issue

Hi,

What is the error in console?

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

HTTP Status 400 -

type Status report

message

description The request sent by the client was syntactically incorrect ().

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Push Notification API Issue

Where do you paste it?
This is an incorrect syntax: codedata:/code

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

I am using AJAX

code
$.ajax({
type: 'GET',
beforeSend: function(request) {
request&#46;setRequestHeader('X-Appery-Database-Id', '<db_id>');
},
url: 'https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/questions/',
dataType: 'json',
data: {
where: '{"sid":'+sid+'}',
sort: "-_createdAt",
},

success: function(qlist) {
console&#46;log(qlist)
}
});
/code

Where should I put the 'sort' and if I need it descending, where do I put the '-'?

Thanks

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

I am using AJAX so sent it:

code
&#47;&#47; push to devices
$&#46;ajax({
type: 'POST',
dataType: 'json',
contentType: 'json',
beforeSend: function(request) {
request&#46;setRequestHeader('Appery-Push-API-Key', 'api_key');
},
url: 'https:&#47;&#47;api&#46;appery&#46;io/rest/push/msg',
data: '{"payload":{"message" : '+message+', "badge" : 0}, [ "filter" : {"lc" : "'+ sname +'"}]}',
success: function(res) {
console&#46;log(res);
},
error: function(xhr, ajaxOptions, thrownError) {
console&#46;log("Load error: " + xhr&#46;status + " " + xhr&#46;responseText);
}
});
},
error: function(xhr, ajaxOptions, thrownError) {
console&#46;log("Load error: " + xhr&#46;status + " " + xhr&#46;responseText);
}
});
/code
This is not sending the message, and I get the above error :(

Thanks

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

Any joy on this please. I hope this is the last syntax issue i have.. fingers crossed

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Push Notification API Issue

Hello! Sorry, not yet. Working on it.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Push Notification API Issue

This code works for us pre$&#46;ajax({
type: 'POST',
dataType: 'json',
contentType: 'json',
beforeSend: function(request) {
request&#46;setRequestHeader('X-Appery-Push-API-Key', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx');
request&#46;setRequestHeader('Content-Type', 'application/json');
},
url: 'https:&#47;&#47;api&#46;appery&#46;io/rest/push/msg',
data: '{"payload":{"message" : "'+message+'", "badge" : 0}, "status": "sent", "filter" : {"lc" : "'+ sname +'"}}',
success: function(res) {
console&#46;log(res);
},
error: function(xhr, ajaxOptions, thrownError) {
console&#46;log("Load error: " + xhr&#46;status + " " + xhr&#46;responseText);
}
});/pre

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Push Notification API Issue

Thank you, I will try it now :)

Return to “Issues”