Page 1 of 2

Push Notification API Issue

Posted: Wed Feb 12, 2014 5:49 pm
by Bad Addy

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.


Push Notification API Issue

Posted: Wed Feb 12, 2014 6:19 pm
by Kateryna Grynko

Hi,

What is the error in console?


Push Notification API Issue

Posted: Wed Feb 12, 2014 6:42 pm
by Bad Addy

HTTP Status 400 -

type Status report

message

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


Push Notification API Issue

Posted: Wed Feb 12, 2014 9:33 pm
by Kateryna Grynko

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


Push Notification API Issue

Posted: Wed Feb 12, 2014 9:51 pm
by Bad Addy

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


Push Notification API Issue

Posted: Wed Feb 12, 2014 9:53 pm
by Bad Addy

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


Push Notification API Issue

Posted: Thu Feb 13, 2014 8:23 am
by Bad Addy

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


Push Notification API Issue

Posted: Thu Feb 13, 2014 11:18 am
by Maryna Brodina

Hello! Sorry, not yet. Working on it.


Push Notification API Issue

Posted: Thu Feb 13, 2014 1:36 pm
by Maryna Brodina

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


Push Notification API Issue

Posted: Thu Feb 13, 2014 1:41 pm
by Bad Addy

Thank you, I will try it now :)