Closed mginz83 closed 7 years ago
You're using the onesignal API, I'M not sure what about parse-server is there. perhaps that's just because you don't send response.success() / response.error()
Thats exactly what was wrong.
For those who find this later on. Here is my soluation to use OneSignal for push notifications. This code is meant for my friending system so it sends the notification to a specific person.
Parse.Cloud.define('replyFriendRequest', function(request, response) {
var personSending = request.params.sendingPerson;
var personGetting = request.params.sendToPerson;
Parse.Cloud.httpRequest({
url: "https://onesignal.com/api/v1/notifications",
method: "POST",
headers: {
'Content-Type': 'application/json;charset=utf-8',
"Authorization": "Basic REST_KEY"
},
body: {
app_id: "APP_ID",
include_player_ids: [personGetting],
headings: {en: "New Friend!"},
contents: {en: personSending + " accepted your friend request!"}
},
success: function(httpResponse) {
response.success("sent");
},
error: function(httpResponse) {
response.error('Failed with: ' + httpResponse.status);
}
});
});
So the above code will work. However, I get a total of 4 pushes on my device and still an i/o error.
Any reason why????