◉RORK LABJP
●ARCHIVE — Since 11/22 you can archive a Rork project instead of deleting it, and bring it back from Archived●PLAY FIX — Fixed: Expo apps built for Google Play losing their Rork AI key, which broke AI features●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 7 days left. Check which model your app calls●SPLASH — Expo users report apps stuck on the splash screen after rolling back to an earlier update●NEW — New: Three clues to check before replying to a "stuck on the splash screen" review●2.5 ROUTE — From 12/1, Gemini 2.5 requests reroute to newer models at new rates. 8 days left●ARCHIVE — Since 11/22 you can archive a Rork project instead of deleting it, and bring it back from Archived●PLAY FIX — Fixed: Expo apps built for Google Play losing their Rork AI key, which broke AI features●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 7 days left. Check which model your app calls●SPLASH — Expo users report apps stuck on the splash screen after rolling back to an earlier update●NEW — New: Three clues to check before replying to a "stuck on the splash screen" review●2.5 ROUTE — From 12/1, Gemini 2.5 requests reroute to newer models at new rates. 8 days left
Articles/App Dev
◇ App Dev/2026-07-03Intermediate

Making Your Rork Max App Resilient to Dropped and Restored Connections: Offline Detection and Retry with NWPathMonitor

Build networking that survives a lost signal in your Rork Max native Swift app with NWPathMonitor. Detect offline states, respect Low Data Mode and cellular, and auto-resend queued work on reconnect — all with working Swift code.

Rork Max236NWPathMonitorNetwork3Offline3Swift48iOS118

✦ Premium Article

Back when I was handing out a beta of a notes app, I received a handful of reports saying "the note I wrote disappeared." I couldn't reproduce it on my own device. Digging through the logs, the one thing they had in common was that the save had happened inside a subway car or an elevator. Tapping save with no connection failed silently, and the screen simply closed as if nothing had gone wrong. To the user, it looked like the note had been saved.

As an indie developer, I find this kind of bug the most insidious. A crash is at least visible. Data that vanishes quietly erodes trust while nobody notices.

With Rork Max's native Swift, you can watch the state of the network path in real time using NWPathMonitor from Apple's Network framework. In this article we'll wrap that monitoring into something the whole app can share, then build offline signaling, behavior that adapts to the connection type, and automatic resend on recovery — all with code that actually runs.

Why "ping the server to check" is the wrong instinct

When people think about detecting offline states, a common first idea is to fire a lightweight request at the server on launch and read success or failure. I did exactly that at first. But the approach is weak in two ways.

First, it can't capture the possibility that the signal drops the instant after the ping succeeds. Connectivity changes continuously, so checking it at a single point in time tells you little.

Second, Apple itself discourages pre-flighting reachability. The NWPathMonitor documentation frames it clearly: judge whether you can connect by actually attempting the connection, and observe path changes with the monitor. Rather than deciding "can I get through?" before sending, the better posture is to keep watching whether a path exists right now, wait if there isn't one, and flush when it comes back.

NWPathMonitor reports the state of the currently available path across interfaces — Wi-Fi, cellular, wired. And it tells you more than "connected or not": it also reveals whether that path is expensive (cellular, tethering) and whether it's constrained (Low Data Mode).

Wrap NWPathMonitor in a single monitor

Start by consolidating the monitoring in one place. Creating an NWPathMonitor per screen leads to scattered state and missed updates. Hold exactly one for the app and expose it as an ObservableObject that SwiftUI can subscribe to.

import Foundation
import Network
import Combine
 
@MainActor
final class NetworkMonitor: ObservableObject {
    static let shared = NetworkMonitor()
 
    @Published private(set) var isConnected = true
    @Published private(set) var isExpensive = false      // cellular, tethering
    @Published private(set) var isConstrained = false     // Low Data Mode
    @Published private(set) var pathStatus: NWPath.Status = .satisfied
 
    private let monitor = NWPathMonitor()
    private let queue = DispatchQueue(label: "NetworkMonitor")
 
    private init() {
        monitor.pathUpdateHandler = { [weak self] path in
            // pathUpdateHandler is called on a background queue
            Task { @MainActor in
                self?.apply(path)
            }
        }
        monitor.start(queue: queue)
    }
 
    private func apply(_ path: NWPath) {
        pathStatus = path.status
        isConnected = path.status == .satisfied
        isExpensive = path.isExpensive
        isConstrained = path.isConstrained
    }
 
    deinit {
        monitor.cancel()
    }
}

Two things matter here. pathUpdateHandler is invoked on the dedicated queue you passed to start(queue:) — a background queue. Touching @Published directly there moves UI updates off the main thread and causes warnings and flicker. That's why we hop to the main actor with Task { @MainActor in } before applying anything.

The second is that monitor.start must be called exactly once. Making the ObservableObject a single shared instance also guards against starting it more than once.

If you scaffold this with a Rork Max prompt, phrase it like this to get a close skeleton:

Using the Network framework's NWPathMonitor, create a @MainActor
ObservableObject that publishes isConnected / isExpensive / isConstrained
via @Published. Marshal the pathUpdateHandler result onto the MainActor
before applying it.

The generated code is usually usable as-is once you confirm the pathUpdateHandler isn't touching @Published off the main thread and that start(queue:) isn't called more than once.

✦

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
✦Take home a working NetworkMonitor ObservableObject that lets any SwiftUI view subscribe to connectivity state
✦Learn to translate not just path.status but isExpensive and isConstrained into concrete UX decisions
✦Get a reconnect-triggered send queue that flushes failed requests the moment connectivity returns, plus the production pitfalls
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-04-05
Rork Max × WidgetKit & Live Activities in Practice — From Home Screen to Dynamic Island
A complete guide to implementing iOS Widgets, Lock Screen widgets, and Dynamic Island Live Activities with Rork Max. Covers WidgetKit fundamentals, Timeline update strategies, App Intents integration, and monetization.
◇ App Dev2026-10-26
Linking.canOpenURL Keeps Returning false on iOS Only — Declaring LSApplicationQueriesSchemes, and the 25-Entry Cap Coming With iOS 27
When Linking.canOpenURL returns false on iOS no matter what is installed, the cause is usually a missing Info.plist declaration. Here is how to fix it in Expo's app.json, what Android needs instead, and how to prepare for the 25-entry limit for apps linked on iOS 27.
◇ App Dev2026-10-15
When adjustsFontSizeToFit Shrinks Just One Row, Suspect the Box Height, Not the String
Only the 10th row of a list drops to 4pt on iOS, though the data and strings are fine. I read the Yoga rounding and font-fit sources, then counted how often the box comes up short in Node.