Unable to schedule push notifications - always firing immediately
Issue Description
I am unable to get scheduled push notifications to fire at the date/time specified in the push_time property using parse-server on node. No matter what time I specify, or what format (js Date object, ISOString, etc) it always fires the push immediately. I am receiving on iOS client.
Steps to reproduce
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
following Hector's post at https://www.parse.com/questions/push-to-local-timezone-from-cloud-code...
var query = new Parse.Query(Parse.User);
return query.find().then(function(users) {
var installQ = new Parse.Query(Parse.Installation);
installQ.containedIn('user', users);
return Parse.Push.send({
where: installQ,
push_time: '2016-08-29T12:00:00.00',
data: {
alert: alert
}
}, {
useMasterKey: true
}).then(function() {
console.log('done');
}, function(error) {
console.log(error);
})
});
Expected Results
iOS client receives push notification at local lime specified in push_time 2016-08-29T12:00:00.00
Actual Outcome
iOS client receives push notification immediately
Environment Setup
- Server
- parse-server version 2.2.18
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
- Database
- MongoDB version: 3.0.10
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mlab
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
Push scheduling is not supported on parse-server and are not likely to be supported in a short future (for the same reason jobs scheduling is not supported). PR are welcome, as always.
could you tell us how to implement this function as scheduling push.
I'm not sure I'll be able to help with that, and also not sure we want to implement a scheduling engine at large at it implies many choices and it's likely not to work correctly in scaled environments.
There's really no need to put this functionality into parse-server as scheduling services already exist and choosing the right one for your environment is better than trying to build a good solution into parse-server.
You can use an existing scheduler like cron that can then call a cloud function to send your notifications.
In our case, we're on AWS Elastic Beanstalk, so it made sense to use AWS services to implement scheduling. We have a CloudWatch event that is scheduled to fire at a particular time twice a day. The event invokes a Lambda function that calls the cloud function. Rock solid.
Is there a reason to keep the "scheduling pushes" session on JS SDK documentation? As it is not being used anymore...
@flovilmart Is there a way we can use Heroku Scheduler for Scheduling push notifications ? Because I have used Heroku Scheduler for scheduling jobs. And every notification has different scheduled time. It's not a
We'd need to implement some kind of scheduling adapter, that would enable you to use the heroku scheduler. Also, we'd need to store the pushes according to the schedule.
How can i schedule my push using cloud post ?
My code var msg = request.params.message; var channel = request.params.channel; var date = request.params.dateTime;
Parse.Push.send({
channels: [channel],
data: {
alert: msg,
badge: "Increment",
sound: 'default'
},
push_time: new Date(date)
},
{
success: function () {
console.log('##### PUSH OK', channel, new Date(date));
},
error: function (error) {
console.log('##### PUSH ERROR');
},
useMasterKey: true
});