简体   繁体   English

发送非活动Ruby on Rails的自动推送通知

[英]Sending automatic push notification for inactivity Ruby on Rails

In my app i'm using RPush Gem to implement push notifications. 在我的应用中,我正在使用RPush Gem来实现推送通知。 Right now admin can send a custom message as notification. 现在,管理员可以发送自定义消息作为通知。

What I want is to send an automatic notification if the user hasn't logged in for 2 days. 我想要的是在用户两天未登录时发送自动通知。 I can check this in my database where I'm keeping a record like last_logged. 我可以在我的数据库中检查此记录,并保存类似last_logged的记录。 But i want to know how to check this automatically and run in background. 但是我想知道如何自动检查它并在后台运行。

Hard to give better suggestions without more detail, but if you're on a platform like Heroku, you can do scheduled cron jobs using their scheduler add on. 在没有更多细节的情况下很难给出更好的建议,但是如果您使用的是Heroku这样的平台,则可以使用其计划程序插件执行计划的cron作业。 So the idea is: 因此,想法是:

1) Implement a rake task that checks whether a user hasn't logged in for 2 days, then send an email to yourself (or whomever) 2) Schedule this rake task via Heroku Scheduler add on 1)实施一个rake任务,检查用户是否已登录2天,然后向您自己(或任何人)发送电子邮件2)通过Heroku Scheduler安排此rake任务

If you're not using Heroku, I'm sure there are equally compatible services you can try to run a cron job. 如果您不使用Heroku,我确定您可以使用同样兼容的服务来尝试执行cron作业。

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

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