Skip to content Skip to sidebar Skip to footer

Parse Push Notification Not Firing On Time

In my application the user creates an alarm which uploads an object to parse as well as schedules a push notification for the time that they select. I had it working yesterday but

Solution 1:

Jack I can't duplicate your error when building from ground up. There are a couple things you might be overlooking that i've outlined below. If your dead set on using Cloud Code the correct way to send a scheduled push is below. But first lets discuss since I can't reproduce your error, brainstorming might prevail in this case.

var query = new Parse.Query(Parse.Installation);
query.equalTo('deviceType', 'ios');

Parse.Push.send({
where: query,
"data" : { "content-available": 1, 
"sound": "",
"extra": {"Time": alarmTime} //confused what your trying to do here. 
}
//remaining code

extra is not a supported field for the data dictionary. Unless you created your own but I don't see that anywhere else in your code. And I don't know why would have to create a new dictionary for it anyways? Additionally if you did want to create a new field the data is only presented once the user has opened the app after tapping on the notification.

CORRECT SYNTAX WITH CLOUD CODE

var query = new Parse.Query(Parse.Installation);
query.equalTo('deviceType', 'ios');

Parse.Push.send({
where: query,
data : { 
alert: "Push from the Future!",
badge: "Increment",
sound: "",
}
push_time: new Date(2015, 01, 01) // Can't be no more than two weeks from today see notes below
}, {
success: function() {
//Success
},
error: function(error) {
//Oops
}
});

However, I would urge you to not use Cloud Code unless you absolutely have to. There are other ways of firing local push notifications, specifically Apples way. It's user friendly and easy to incorporate for tasks like this. Another reason, is because for every query you execute it counts against your API Requests as 1 request. This could easily multiply if you plan on expanding your app or growing the audience in the future. Which goes back to the first reason, send a local push notification from the device.

There is also a couple things to consider when scheduling the way you want through cloud code.

  1. The scheduled time cannot be in the past, and can be up to two weeks in the future
  2. It can be an ISO 8601 date (which is basically the internationally accepted way to represent YYYY-MM-DD) with a date, time, and timezone, as in the example above, or it can be a numeric value representing a UNIX epoch time in seconds (UTC)
  3. Ensure you have the latest version of Parse installed

Post a Comment for "Parse Push Notification Not Firing On Time"