Daily iOS
Persistence

Offline chat storage design

Chat in a secondhand marketplace app has to work for reading and writing on the subway. Design the local database schema and the sync flow so that messages sent offline reach the server later and order, duplicates, and read state stay straight.

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

The local database is the source of truth, and a message carries a localId, a serverId, a status (pending, sent, failed), and the server seq. Sending inserts locally and an outbox queue transmits, the server takes the localId as an idempotency key, ordering comes from the server seq, and on reconnect you take only the delta after lastSeq.

Share a question