Amba
Platform

Offline Sync

Queue actions offline and sync when the device comes back online.

The client SDK queues actions (events, streak qualifications, purchases) when the device is offline and syncs them when connectivity is restored.

How it works

  1. When the device is offline, SDK methods queue operations locally
  2. When connectivity returns, the queue is flushed in order
  3. The server processes queued operations with conflict resolution
  4. Failed operations are retried with exponential backoff

Client API reference

MethodPathDescription
POST/client/syncSync queued operations

Sync payload

POST /client/sync
{
  "operations": [
    { "type": "event", "payload": { "event": "workout_completed", "properties": {} }, "queued_at": "2025-01-14T10:00:00Z" },
    { "type": "streak_qualify", "payload": { "streak_id": "streak_xxx" }, "queued_at": "2025-01-14T10:00:01Z" }
  ]
}

The server processes operations in order, using queued_at timestamps for proper sequencing.

SDK configuration

const client = Amba.configure({
  projectId: 'proj_xxx',
  apiKey: 'ak_client_xxx',
  // Offline sync is enabled by default when using persistent storage
  storage: new AsyncStorageAdapter(), // or ExpoSecureStore
});

On this page