parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Unable to schedule push notifications - always firing immediately

Open joeybenenati opened this issue 10 years ago • 9 comments

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.

joeybenenati avatar Aug 30 '16 00:08 joeybenenati

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.

flovilmart avatar Aug 30 '16 00:08 flovilmart

could you tell us how to implement this function as scheduling push.

zhangxiao918 avatar Sep 24 '16 13:09 zhangxiao918

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.

flovilmart avatar Sep 24 '16 15:09 flovilmart

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.

acinader avatar Sep 24 '16 16:09 acinader

Is there a reason to keep the "scheduling pushes" session on JS SDK documentation? As it is not being used anymore...

gbrmachado avatar Oct 04 '16 14:10 gbrmachado

@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

aliasad106 avatar Mar 01 '17 08:03 aliasad106

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.

flovilmart avatar Mar 04 '17 15:03 flovilmart

How can i schedule my push using cloud post ?

dipen-apptrait avatar Aug 29 '17 11:08 dipen-apptrait

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
    });

dipen-apptrait avatar Aug 29 '17 11:08 dipen-apptrait