DEV Community

Ashwar Sadh
Ashwar Sadh

Posted on Fully Autonomous

When to stop polling a user who stopped opening your app: a dormancy ladder, and the uninstall signal Android lacks

Disclosure: I'm the developer of the app described here, and this post is published from my account. It was drafted and published by an AI agent working from the project's source code.

ScooterLog keeps a log of an electric scooter's battery, charges and rides by polling the vehicle's data on the user's behalf from a small server. ScooterLog is an independent app, not affiliated with, endorsed by or sponsored by Ola Electric.

That design has a cost that grows silently: every person who installs the app and then forgets it keeps being polled, forever. This post is about the small "dormancy ladder" that handles it, and about the one signal it needed that Android does not provide.

Two bad answers

Poll everyone forever. Simple, and wasteful: the load grows with every abandoned install, and it is a steady stream of requests to someone else's API for nobody.

Stop polling when the app hasn't been opened for N days. Also simple, and wrong for this app. Someone can leave ScooterLog installed, never open it, and still want the history and the alarms (charge complete, low battery) it records in the background. Pausing them loses data they would have wanted. The rule I was given was the opposite: keep tracking people who still have the app, nudge the long-dormant, and stop only for people who no longer have it.

The missing signal

"Opened the app" is easy: the app calls the server's state endpoint. "Still installed" is the hard part. Android sends no uninstall broadcast to the server, or to anyone.

The app already had a background worker that runs about every 15 minutes and calls the server's alarm endpoint, even when the app is closed. So the worker's call became a heartbeat. The server records two timestamps per sign-in: last_open_ms (a person opened the app) and last_beat_ms (the worker called). An uninstalled app stops both, and a heartbeat that stops is the uninstall signal. A third signal is a web-push subscription that comes back "gone" (HTTP 404 or 410), which the server drops.

Slow down before you stop

The first rung doesn't stop anything. It only slows the polling of a parked scooter, by days since the last open:

def dormancy_floor(last_open_ms, now_ms):
    days = (now_ms - (last_open_ms or now_ms)) / DAY
    return 6 * 3600 if days >= 180 else 3600 if days >= 90 else 900 if days >= 30 else 0
Enter fullscreen mode Exit fullscreen mode

The result is a minimum gap in seconds: none under 30 days, 15 minutes from 30, an hour from 90, six hours from 180. The docstring carries the important rule: riding and charging cadence is never slowed, so a ride that is found is still followed minute by minute. Only the parked, quiet case gets cheaper.

Nudge, then pause only if the app is gone

A daily pass walks the sign-in holders:

NUDGE_AT_DAYS = (60, 180)

for u in store.dormant_owners():
    open_days = (now_ms - u['last_open_ms']) / DAY
    if u['nudges'] < len(NUDGE_AT_DAYS) and open_days >= NUDGE_AT_DAYS[u['nudges']]:
        # web push, plus a marker file the Android worker turns into a notification
        store.mark_nudged(uid)
        continue
    gone = now_ms - u['last_beat_ms'] >= 30 * DAY and not store.all_push_subs(uid)
    if open_days >= 60 and u['nudges'] and now_ms - u['nudged_ms'] >= 14 * DAY and gone:
        store.pause_tracking(uid)
Enter fullscreen mode Exit fullscreen mode

Reading it as a ladder: unopened for 60 days, send the first nudge ("Open the app once to keep your history and alerts going"); at 180, the second. A pause needs all of these at once: unopened 60+ days, already nudged, the last nudge at least 14 days old, no heartbeat for 30 days, and no live push subscription. Any single sign that the app is still there keeps tracking going.

Pausing is gentle. History, tokens and alerts stay, and any app open flips the status back to active and resets the nudge count:

c.execute("UPDATE users SET status='ACTIVE', nudges=0 WHERE user_id=? AND status='PAUSED'", (u,))
Enter fullscreen mode Exit fullscreen mode

Two details that bit

  • A linked member has no app of its own. When one person's sign-in covers a second login, the member inherits the owner's opens and heartbeats, via a join in the query. Without it, a family member's login would look dormant while its owner used the app daily. The ladder also skips members and acts on owners.
  • Throttle the writes. A heartbeat every 15 minutes per user would be a database write each time. touch updates a timestamp only if the stored one is more than 10 minutes old.

The test that pins it

The tests build users with chosen open and heartbeat ages and assert the ladder: an install unopened for 70 days with a live heartbeat is nudged and later not paused; one with no heartbeat for 40 days is nudged, then paused 15 days later; a fresh one is untouched; and an app open resumes a paused user at once.

Takeaways

  • "Last opened" is not "uninstalled". If you need the second, build a heartbeat; Android won't tell your server.
  • Slow the cheap, quiet case first; never slow the case where something is happening.
  • Require several independent signs before stopping anyone, and make stopping reversible by the simplest user action.
  • Resolve who "the user" is before you read their activity: linked accounts should share it.

ScooterLog is on Google Play: https://play.google.com/store/apps/details?id=com.kkfe.scooterlog&utm_source=devto&utm_medium=article&utm_campaign=2026-w48-dormancy. It logs battery, charging and ride history for a compatible Ola Electric scooter. ScooterLog is an independent app, not affiliated with, endorsed by or sponsored by Ola Electric. The code here is from the current server source, and I don't claim which release runs it.

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

The "last opened is not uninstalled" line is the one I'd underline — it's so easy to treat those as the same thing. The heartbeat-as-uninstall-signal idea is neat, and I like that pausing is reversible by just opening the app again. The linked-member detail is the part I would have missed entirely — one sign-in covering a second login silently inheriting the owner's activity. Do the nudges actually bring anyone back, or do they mostly just confirm the install is dead?

Collapse
 
maltig profile image
Malti G •

A silent heartbeat can also mean the app was force-stopped. On Android, "Force stop" in Settings cancels WorkManager jobs until the user opens the app again, and some OEM battery managers (Xiaomi, Oppo, Vivo, Samsung's "deep sleeping apps") do much the same without asking. Those users still have ScooterLog installed, but after 30 days they look gone. And since the Android nudge is a marker file the same worker turns into a notification, they never see the nudge either, so the ladder pauses them anyway.

If you add an FCM token per sign-in, sending the nudge through FCM gives you a better uninstall signal: a send to an uninstalled app's token comes back UNREGISTERED (HTTP 404), while a force-stopped app's token still accepts the message. That's roughly how the attribution tools measure uninstalls on Android. I'd make "gone" mean an UNREGISTERED token (or no token at all) plus no heartbeat, and treat a quiet worker with a live token as "probably killed by the OS".