1

I'm developing a gym website using Angular 6 with service workers that needs to send notifications to users (Web push notifications) when the class they are subscribed to is going to begin (for example 15 minutes before the start time).

By the time I have a PHP function that uses Minishlink\WebPush to send the notification, so I need to call that function 15 minutes before the class starts, and it has to be done automatically because there's no interaction of the user in order to call that function.

I've thought about having a MySQL event that consults the table where classes are stored, and when the time has arrived calls that PHP function but I don't know how to do it, and even if it is the best idea.

Any suggestions?

I'm using Angular 6 + PHP + MySQL running locally on XAMPP.

Umar Abdullah
  • 1,282
  • 1
  • 19
  • 37

1 Answers1

0

the best way to this and handle such situation is to create a cron and dynamic cron timing to execute Minishlink\WebPush send function.

we have also handled such situation using cron, but the use case was different. our cron runs every 15 mins checks the if data is there in mongo DB if it is there send a push notification to that user.

in your case, you can create a specific cron task as soon as user scheduled his timings more helpful information is here on this answer.

I hope this will help you.

Hrishikesh Kale
  • 6,140
  • 4
  • 18
  • 27
  • Good information!! he is right, what you need is a cron job. BTW, this should be a comment – Patricio Vargas Jan 13 '19 at 07:44
  • Thank you for the information ! I will go forward on this approach. Just a question because I have never done it. When time comes to deploy the app on a server for production (I still don't know where), is it possible to add the generated Cron? – Sebastián Yomha Jan 13 '19 at 12:31
  • yes absolutely possible because cron is a Linux utility which schedules a command or script on your server to run automatically at a specified time and date. A cron job is the scheduled task itself. also, it depends on which server you are using. there are many solutions for adding a cron job on the internet. happy coding brother. – Hrishikesh Kale Jan 14 '19 at 04:19