1

Since Scheduled push is not available on Parse , I'm using setTimeout() to schedule pushes. I'm using back4app.

// I call this cloud code
Parse.Cloud.define("pushMultiple",async (request) => {
//Using set timeout to send out a push 1 hour later
  setTimeout(pushout,100000);
});

//The function to send Notificaiton 
const pushout = () => {
        Parse.Push.send({
          channels: [ "t1g.com"],
          data: {alert: "The Giants won against the Mets 2-3."}
         },{ useMasterKey: true });
}

My code works fine. So my question is this:

1) Is my method reliable?

2) What can the disadvantages of this be ?

3) How many setTimeouts() can be queued on the server, is there any sort of limit ?

T.I.A

Tom Fox
  • 897
  • 3
  • 14
  • 34
Tanzim Chowdhury
  • 3,020
  • 2
  • 9
  • 21
  • 1
    Why don't you use sheduled cron jobs? I believe back4app supports cron jobs. Save necessary push information to database. Then run a cloud code every "x" time. If push time is come your cloud code sends the push. `SetTimeOut()` method , I believe keeps the istance or reference of cloud code. Which means your cloud code is still "working" even its just waiting, Parse server should be keeping the instance of it. That means you wast your resources. Also I believe back4app has a cloud code timeout. Even you use `setTimeOut()` for one hour cloud code will be terminated after timeout. – uzaysan Apr 13 '20 at 07:48
  • I've been thinking the same. Thank you for the clarification. You may use your comment to answer my question because it's correct. – Tanzim Chowdhury Apr 14 '20 at 08:44
  • Hi, you don't need to re-post your question, you can edit your existing question [Schedule Push notification on Parse](https://stackoverflow.com/questions/61026124/schedule-push-notification-on-parse). Please delete this copy, use the buttons below the question for that. – Manuel Apr 23 '20 at 15:57
  • @Manuel Hello , the question was not re-posted, they might sound the same but they are both completely different. – Tanzim Chowdhury Jun 09 '20 at 13:14
  • In this question you are asking whether `setTimeout` to delay pushes is reliable and what the disadvantages can be. In the other question you are sharing the same code and ask whether it "is wrong or harmful in anyway or if there is a better way of doing it". There is no essential difference in these two questions. – Manuel Jun 09 '20 at 13:19
  • @Manuel Oh right , now I see the confusion . The original question was whether scheduled push is supported and someone answered that "it's not supported". But then I updated the question saying that using setTimeout is a possible solution so what are the advantages or disadvantages but It seemed no one answered there so I posted this question here. I think I should remove the update from my previous question ? that would make more sense. But like I said completely different questions. One asks if Schedules push is possible , another one asks if setTimeout() should be used. – Tanzim Chowdhury Jun 09 '20 at 16:29
  • Does this answer your question? [Schedule Push notification on Parse](https://stackoverflow.com/questions/61026124/schedule-push-notification-on-parse) – Manuel Jun 09 '20 at 16:46
  • I have fixed it , now these are two separate questions. Thankyou for pointing it out – Tanzim Chowdhury Jun 09 '20 at 17:39

1 Answers1

2

Why don't you use sheduled cron jobs? I believe back4app supports cron jobs. Save necessary push information to database. Then run a cloud code every "x" time. If push time is come your cloud code sends the push. SetTimeOut() method , I believe keeps the istance or reference of cloud code. Which means your cloud code is still "working" even its just waiting, Parse server should be keeping the instance of it. That means you wast your resources. Also I believe back4app has a cloud code timeout. Even you use setTimeOut() for one hour cloud code will be terminated after timeout.

uzaysan
  • 583
  • 1
  • 4
  • 18