简体   繁体   中英

How to send Web push notifications automatically when database event occurs? Angular + PHP + MySQL

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM