Başar BallıözProduct Engineer
← All posts

Maintenance reminders by date and mileage, sent with Expo push notifications

A car app is only as useful as its reminders. Getting a phone to buzz is easy. Getting it to buzz once, on the right morning, for the thing that is actually due, and never twice, took a small amount of careful code.

By Başar Ballıöz · · 4 min read

The short answer

To send maintenance reminders from a Node.js backend to an Expo app: compute what is due from each car's records, run one job a day from a cron, give every notification a dedupe key so a retry never sends it twice, send through Expo's push API in batches, and come back for the push receipts later to remove tokens of uninstalled apps. Guard the job with a lease so two runs can never overlap.

When I wrote about why I built RPMBase, I said reminders beat reports. This is how those reminders work.

For the mileage half of the rule, RPMBase's free oil change due calculator works out when the next change is due, no app needed.

1. What is due: date or mileage, whichever comes first

A reminder is built from the car's own data, not stored separately, so it can never drift from the records:

  • Documents with a date: insurance, kasko (comprehensive cover), inspection and any uploaded document with an expiry date.
  • Maintenance: for each service type, only the latest record counts, and it can have a next due date, a next due mileage, or both.

Each one gets a status. A date is "due soon" within 14 days; a mileage is "due soon" within 500 km. When a service has both, the more urgent of the two wins: an oil change that is 300 km away is due soon even if its date is months off. Overdue items sort first, then the rest by days left.

The same function feeds the app's home screen and the notifications, so what the phone says and what the screen shows always agree.

2. One job a day, guarded by a lease

The API runs on Vercel, and a Vercel cron calls the dispatch endpoint once a day at 06:00 UTC, which is 09:00 in Istanbul, a reasonable hour to hear about your insurance. The endpoint only accepts the call with a long secret, so nobody else can trigger a send.

Cron calls can be retried or, in rare cases, arrive twice. So the job first takes a lease in the database: a row that says "a dispatch is running" and expires on its own after two minutes. If the lease is taken, the second run stops immediately. A crashed run cannot block tomorrow's, because the lease expires.

Dates are computed as the civil date in Istanbul, not UTC. A reminder about "tomorrow" means the user's tomorrow, and a job that runs near midnight UTC does not shift a day.

3. Dedupe keys: never the same message twice

Every message carries a key built from what it is about: the reminder's id, its status and the date, for example car 12, inspection, due soon, 2026-12-02. Each user's state keeps the most recent keys it has sent. Before sending, the job skips anything whose key is already there.

That one rule makes the whole job safe to rerun. If it fails halfway, the next run sends what is left and nothing else. And because the status is part of the key, a reminder that moves from "due soon" to "overdue" can notify again, once, which is exactly the behaviour you want.

4. A weekly summary instead of a daily stream

Daily reminders for every item would turn into noise. Besides individual reminders for things that changed status, RPMBase sends one weekly summary: up to four lines listing what is due this week. Its key is the ISO week (Monday start, Istanbul time), so it goes out once per week, however many times the job runs.

Premium expiry gets its own short reminders a few days before the end, with the same dedupe rule.

5. Sending through Expo, and reading the receipts

The app registers an Expo push token, and the server checks that a token looks like one before storing it. Sending is a POST to Expo's push endpoint in chunks of 100 messages, the API's limit per request. Expo answers with a ticket per message, and a ticket only means "accepted", not "delivered".

The real result comes later as a push receipt. The job stores the receipt ids and, on the next run, asks for them in chunks of 300. A receipt with the error DeviceNotRegistered means the app was uninstalled or the token is dead, so that token is removed from the user. Without this step the list of tokens only grows, and every send wastes calls on phones that will never show the message.

6. The user's language and their choices

Notification text is built on the server, in Turkish or English depending on the user. There are two switches in settings, maintenance reminders and document expiry, both on by default, and the job reads them before it builds anything.

Common questions

Should reminders be scheduled on the phone instead?

Local notifications work for fixed dates, but mileage changes whenever the user logs a fill-up, and data may be edited on another device. Computing reminders on the server from current records keeps them correct.

How do I avoid duplicate push notifications from a cron job?

Give every message a deterministic key, store sent keys, skip known ones, and use a lease so two runs never overlap.

What does DeviceNotRegistered mean in Expo push receipts?

The token no longer reaches an installed app. Remove it from your database.

What I learned

Compute reminders, do not store them. Built from the records every time, they never go stale.

Idempotency is the feature. A dedupe key plus a lease turned a job that could spam users into one that can be rerun at any time.

Less is kinder. One weekly summary and a message when something changes keeps people reading the notifications that matter.

More posts

LLM API cost control per user: how RPMBase keeps the AI bill boundedHow RPMBase keeps OpenAI costs bounded per user: server-side limits, a worst-case cost reservation, atomic budgets in MongoDB, shared pools for free accounts and a hard cap. Keyword cannibalization in practice: one query, three moves, zero impressionsA real case from RPMVault: moving "motorcycle maintenance app" between pages three times cost its impressions. The query ownership rules, title limits and lock test I use now.