RORK LABJP
PUBLISH — Rork Max handles code signing and provisioning so you can submit to the App Store in two clicksSIMULATOR — A browser streaming simulator feels close to real hardware, and a QR code installs to your device without TestFlightMAX — Rork Max generates native Swift apps, powered by Claude Code and Claude Opus 4.6NATIVE — Rork Max reaches Xcode-class territory: AR/LiDAR, Metal 3D, widgets, Live Activities, HealthKit, and Core MLFUNDING — Rork raised $15M to power the next generation of App Store entrepreneursPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/monthPUBLISH — Rork Max handles code signing and provisioning so you can submit to the App Store in two clicksSIMULATOR — A browser streaming simulator feels close to real hardware, and a QR code installs to your device without TestFlightMAX — Rork Max generates native Swift apps, powered by Claude Code and Claude Opus 4.6NATIVE — Rork Max reaches Xcode-class territory: AR/LiDAR, Metal 3D, widgets, Live Activities, HealthKit, and Core MLFUNDING — Rork raised $15M to power the next generation of App Store entrepreneursPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/month
Articles/Dev Tools
Dev Tools/2026-07-07Intermediate

The App Icon Badge Still Says 3 — Rebuilding Expo Badge Counts Around a Single Source of Truth

Why an Expo app's icon badge drifts out of sync with real unread counts and refuses to clear — and how to rebuild it around a single source of truth, with working recompute-and-sync code and the production pitfalls that bite you.

Expo131React Native196Notifications3BadgeRork489

Premium Article

A few weeks after release, review after review said the same thing: "the red badge stays on 3 and won't clear even when I open the app." This happened in a habit-tracking app I run as an indie developer. Open it and there are zero unread items, yet the home screen icon keeps insisting on "3." From the user's side, the app looks like it's lying.

When I traced it, nothing in the code ever said "set the badge to 3." The badge was being incremented by the notifications themselves, and nobody owned the job of bringing it back down. This article breaks down why that mismatch happens and rebuilds the badge around a value recomputed from state, with the code that got mine to behave.

What actually makes the badge drift

In an Expo (React Native) app, the badge count is written by two different actors that don't know about each other.

One is the notification system. When a local or push notification carries a badge value, the OS rewrites the icon badge on delivery. The other is your app, which only changes the badge when you call Notifications.setBadgeCountAsync().

The trouble is that these two never coordinate. Every time a notification arrives, the OS bumps the badge, but when the user reads that item inside the app, nothing happens unless your code explicitly lowers the badge. What's left behind is the number the notifications piled up.

Worse, the badge value baked into a notification is frozen at the moment that notification was scheduled. If your state changes while the user ignores the notification, a previously scheduled notification still fires with its stale badge. The badge reflects a snapshot from scheduling time, not the count right now.

Pick one source of truth

You can't solve this while you're still thinking in terms of "who writes the badge." The whole problem is that more than one actor writes it.

Flip the framing: define the badge count as something computed uniquely from app state. Unread notices, incomplete tasks, reminders awaiting review — gather whatever should surface on the badge into one function, and let only that function decide the truth. Stop relying on the badge field of notifications entirely.

I built this the same way I once handled the ad-free state for AdMob: anything with several inputs must flow through a single composed function, and you never assemble the state anywhere else. A badge fits that shape perfectly.

Start with a pure function that gathers the contributing state and returns a number.

// badge/computeBadgeCount.ts
// The one function that "computes" the badge from app state.
// Never assemble a badge number anywhere else.
 
import type { AppState } from "../store/types";
 
export function computeBadgeCount(state: AppState): number {
  // Only sum the things you want the badge to represent.
  // e.g. unread notices + overdue incomplete reminders
  const unreadNotices = state.notices.filter((n) => !n.read).length;
  const dueReminders = state.reminders.filter(
    (r) => !r.completed && r.dueAt <= Date.now()
  ).length;
 
  // Normalize at the end so we never emit a negative or NaN
  const total = unreadNotices + dueReminders;
  return Number.isFinite(total) && total > 0 ? total : 0;
}

The function takes only store state as input and has no side effects. It's easy to test, and "what the badge means" now lives in exactly one place.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
If you've been stuck on 'the badge still shows 3 after I open the app' reports, you can ship a recompute-based sync today
You'll replace the double bookkeeping of notification-set badges and app-set badges with one function derived purely from state
You'll implement resync on foreground, on notification receipt, and across iOS/Android differences so the badge never drifts again
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-06-16
Notifications You Can Finish Without Opening the App — Interactive Notification Actions for Rork Apps
Those buttons and text fields that appear when you long-press a notification. Here is how to implement interactive notification actions in a Rork-built Expo app for an experience that completes without launching, including the background-execution pitfalls.
Dev Tools2026-07-04
Should You Show a Read More Link? Let the Rendered Text Decide in Rork (Expo)
Clamping a product description to three lines and adding a Read more toggle sounds simple, until the toggle also appears under single-line text. This walks through measuring the real line count with onTextLayout so the toggle only shows when text actually overflows, covering iOS vs Android quirks, expand animation, and font scaling.
Dev Tools2026-06-29
Adding a keyboard toolbar to Rork text inputs — unifying iOS InputAccessoryView and an Android bar into one component
How to add a toolbar pinned above the keyboard — a Done button or quick-insert actions — to the React Native app Rork generates. The iOS InputAccessoryView and a hand-built Android bar, folded into one reusable component, with working code.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →