While working on a Flutter + Firebase app, we encountered a challenge:
We needed to send push notifications three times before each event — at 48 hours, 24 hours, and 6 hours prior. These notifications had to be sent for all upcoming events to every user on the platform.
At first, we thought the fix was simple — set up a cron job to send notifications on schedule. But there was a catch:
- The frontend can’t handle heavy scheduled tasks
- Our backend was deployed as Firebase Functions, which is a serverless environment that only runs when triggered and doesn’t run all the time
That meant we didn’t have a continuously running server to run a cron job.
How Google Cloud Scheduler Helped :-
After some research, we found Google Cloud Scheduler, a fully managed service designed to run scheduled jobs in the cloud — ideal for serverless setups like Firebase Functions.
Here’s what we did:
- Enabled Cloud Scheduler API in Google Cloud Console
- Deployed Cloud Scheduler in the same region as our Firebase Functions and Firestore for low latency
- Configured Cloud Scheduler to call our Node.js Firebase Function API at the scheduled times
- The function then fetched upcoming events, gathered users’ FCM tokens, and sent push notifications using Firebase Admin SDK
This way, Cloud Scheduler triggers our serverless functions exactly when needed — no need for an always-on server.
Why This Works Well :-
- No need to maintain a separate server just for scheduled tasks
- Serverless functions run only when triggered, saving costs
- Fast and reliable due to same-region deployment
- Automatically scales as your user base and events grow
Summary
If you’re building an app with Firebase Functions and need to run scheduled background tasks, Google Cloud Scheduler is a great choice. It helped us build a reliable notification system without extra infrastructure headaches.