简体   繁体   English

如何在数据库事件发生时自动发送 Web 推送通知? 角 + PHP + MySQL

[英]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).我正在开发一个使用 Angular 6 的健身房网站,其中包含需要在用户订阅的课程开始时(例如在开始时间前 15 分钟)向用户发送通知(Web 推送通知)的服务工作者。

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.当我有一个使用 Minishlink\\WebPush 发送通知的 PHP 函数时,所以我需要在课程开始前 15 分钟调用该函数,并且必须自动完成,因为没有用户交互才能调用那个功能。

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.我想过有一个 MySQL 事件来查询存储类的表,当时间到了时调用该 PHP 函数,但我不知道如何去做,即使这是最好的主意。

Any suggestions?有什么建议?

I'm using Angular 6 + PHP + MySQL running locally on XAMPP.我正在使用在 XAMPP 上本地运行的 Angular 6 + PHP + MySQL。

the best way to this and handle such situation is to create a cron and dynamic cron timing to execute Minishlink\\WebPush send function.处理这种情况的最好方法是创建一个 cron 和动态 cron 定时来执行 Minishlink\\WebPush 发送功能。

we have also handled such situation using cron, but the use case was different.我们也使用 cron 处理过这种情况,但用例不同。 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.我们的 cron 每 15 分钟运行一次,检查 mongo DB 中是否存在数据(如果存在)向该用户发送推送通知。

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.在您的情况下,您可以在用户安排他的时间安排后立即创建特定的 cron 任务,此答案中提供了更多有用的信息

I hope this will help you.我希望这能帮到您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当数据库(MySQL)表更改(插入、更新、删除)发生时,如何在 flutter 中获取推送通知? - How to get push notifications in flutter, when database(MySQL) table change (insert, update, delete) occurs? 如何在MySQL插入新行时自动发送android推送通知? - How to send android push notifications automatically when new row inserted in MySQL? PHP:如何将推送通知发送到Apple设备 - PHP: how to send push notifications to Apple device 如何使用PHP发送iOS推送通知? - How to send iOS push notifications with PHP? 如何在PHP中使用UDID发送推送通知 - How to send push notifications using UDID in PHP Mysql数据库更改状态时使用Push.js推送通知 - Push notifications with Push.js when Mysql database changes status 使用PHP,PDO,MYSQL将Android推送通知发送到多个设备 - Send Android Push Notifications to Multiple Devices using PHP, PDO, MYSQL 如何在mysql数据库中更新值时自动发送电子邮件 - how to send email automatically when a value is updated in mysql database 将通知从Web服务器(PHP和mysql)推送到iOS应用 - Push notifications from web server (php & mysql) to iOS app 如何使用PHP [Swift,Php]将推送通知发送到swift应用 - How to send push notifications to swift app using PHP [Swift,Php]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM