I need some suggestions on how to go about implementing sending an email to a user when they haven't been logged in to an app in say 3 days (in javascript). Basically, notifying a user based on their lastLoggedIn
status which i'd store in the Database. Any pointers will be appreciated.

- 181
- 1
- 8
-
Have a look at this question: https://stackoverflow.com/questions/35737708/how-to-run-cron-job-with-firebase – Aug 15 '19 at 09:17
2 Answers
You can use Cloud Scheduler to create a job with a pubsub
Cloud Function as target, using the same topic
.
Use the frequency option to set the 3 days.
Edit:
Or you can use this new feature:
https://firebase.google.com/docs/functions/schedule-functions
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
return null;
});
Which is basically the same:
When you deploy a scheduled function, the related scheduler job and pub/sub topic are created automatically. The Firebase CLI echoes the topic name, and you can view the job and topic in the GCP Console.

- 919
- 2
- 11
- 33
You should write a cron task for your database.
Like, some code that will run everyday @10.00 AM to check whether user's lastLoggedIn is greater that 3 days. Later on you can notify those pooled users.
Check this nodejs mongodb cron thread that will give you an opinion. Hope it helps!

- 203
- 1
- 6