RORK LABJP
BUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verifyBUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verify
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.

Expo176React Native227Notifications3BadgeRork540

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-30
What Renovate may bump in an Expo app, and what it must never touch
Turning on automated dependency updates in a Rork-generated app also hands Renovate the 123 packages Expo SDK 57 pins. Measured on 2026-07-30, six of them sit a full major version behind npm latest. Here is how to generate the ignore list from the SDK instead of maintaining it by hand.
Dev Tools2026-07-28
Counting what prebuild --clean will erase before you upgrade to Expo SDK 57
A raw diff between two generated ios/ trees showed 649 changed lines; only 3 were real edits. How to count what prebuild --clean erases, and move it into a config plugin.
📚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 →