A user writes a message without a connection, sees it appear in the chat and assumes it was delivered. The app may only have saved a local copy.
An offline messaging feature needs to preserve the message and tell the truth about its state. Making the bubble appear is the easier part.
What should offline messaging promise?
At minimum, define whether the app supports reading previous messages, composing new ones, queuing sends or all three. Those are different capabilities.
For a queued message, the product can promise that the message was saved locally if that write succeeded. It should reserve sent, delivered and read for the evidence those labels require in its own protocol.
Flutter's offline-first guide describes approaches to local and remote state. A chat system adds its own message identity, ordering and acknowledgment rules on top of that architecture.
Persist the message before showing a durable success state
Assign an identity when the message is created, then store the content and outbound state locally. If the local write fails, do not present the message as safely queued.
Here is a proposed design for a Flutter client with a native iOS persistence adapter:
Flutter composer -> Native iOS local outbox
|
v
Application send worker
|
v
Messaging backend
|
v
Explicit acknowledgment
|
v
Local message stateThe diagram proposes responsibilities, not the private implementation of a client product. The outbox could use a different storage layer while preserving the same contract.
Use the original message identity when retrying the same logical send. If every retry receives a new identity, a server that accepted the first attempt before the connection broke may later store a duplicate.
Server-side deduplication also needs a clear scope, such as the sending account and logical message identity. A client-only check cannot resolve every uncertain network outcome.
Give acknowledgment states precise meanings
| Label | Evidence the application should require |
|---|---|
| Saved locally | Local persistence succeeded |
| Queued | The app intends to attempt sending |
| Accepted by server | The backend acknowledged the logical message |
| Delivered | The protocol's defined destination acknowledgment occurred |
| Read | A separate read signal exists, if the product supports one |
The word delivered means different things in different systems. Document your meaning and make it consistent across devices. A successful HTTP response does not automatically establish that the recipient saw the message.
When a send outcome is uncertain, reconcile using the original identity. Do not erase the local message simply because the first network attempt ended in an error.
Test interrupted sends instead of only airplane mode
The difficult case is often a connection that fails halfway through. The server may have committed the message while the client never received the acknowledgment.
A useful review includes closing the app after queuing, losing the connection after the server accepts, retrying after restart and opening the same conversation on another device. Check the stored message count and the labels shown to each participant.
Also test edits and deletions if the product supports them. A queued edit and the original send can arrive in the wrong order unless the protocol defines how to reconcile them.
Background work is another boundary. The mobile operating system controls execution opportunities; do not promise immediate delivery merely because the app requested background work. Apple's Background Tasks documentation describes the platform facilities a real iOS implementation must account for.
Where my offline-messaging experience fits
My work on The Social App included building a native iOS offline-messaging layer and contributing across the Flutter app and backend. The case study describes that contribution without publishing private implementation details or claiming an independently measured delivery-rate improvement.
The design in this article is a public engineering proposal for evaluating an outbox. It should not be read as a disclosure of that product's internal protocol.
Questions about offline chat
Can a message be delivered while the device is offline?
A newly composed message cannot reach a remote service without a working communication path. The app can preserve it and attempt delivery later.
Should retries create a new message?
Not when retrying the same logical send. Preserve its identity and define server behavior for repeated attempts.
Is a local outbox enough to guarantee delivery?
No. Storage, authorization, network availability, server behavior and destination acknowledgment still affect the outcome. The outbox preserves intent and supports recovery; it cannot guarantee the entire path.
Test one message whose acknowledgment is deliberately lost after acceptance. If the app can recover without duplication and explain its state, you have checked a much more useful property than whether a bubble appears without Wi-Fi.