Working offline
What the scanner does with no signal, what waits for signal, and what happens when signal returns, after an app restart, when storage is full and when a capture token expires.
Used in step 2: Scan. Applies to the Timbereye app and to the SDKs in your app.
A worker can scan a whole container with no signal. Each log is saved on the phone before it is counted, and everything uploads by itself when the phone is back online. Final values and events to your backend come after that.
Where it runs. This is how the Swift and Kotlin SDKs work. They are tested off the phone, including crash tests at every upload step, and are not run on phones in this form.
| Works with no signal | Needs signal |
|---|---|
| Measuring and counting on the phone: tag counts, tag scale, AR scale on iPhone (the scale modes need a detector model already on the phone) | Uploading scans, logs and photos |
| Every log written to the phone's disk before it is ticked | Refinement on the server, and so final diameters and volumes |
| Scanning into a group the phone already has the id of (from the app's list, or given by your app) | Events to your backend (group.measured and the rest) |
| The spec the worker picks applied to each log captured (species, length, grade) | Saving a spec change to the group itself (PATCH /groups/{id}) |
| The tally on the phone, as the phone's own estimates | Opening or creating a group, and getting a new capture token |
| GPS on each scan, when the phone has a fix | Downloading the log detector, once |
What the table means in practice:
- The phone needs the group's id or your reference. With the id (created on your server in Step 1, from the Timbereye app's list or given by your app) scanning works with no signal. With your reference (
TimbereyeScanner(reference:…), or New in the Timbereye app), the phone scans offline and the group is created on the server when there is signal; the scans upload into it after that. - Signing in and the group list need signal. The Timbereye app keeps the last list and shows when it was updated.
- A spec change offline. The worker's choice applies at once to the logs captured on that phone, is kept on the phone, and is saved to the group when there is signal (also after a restart). The Swift and Kotlin SDKs both do this.
- No token is needed to capture. The journal stores no keys or tokens; a token is asked for only when uploading.
When signal returns#
Upload starts by itself: on iOS when the network monitor reports a connection (uploads use a background URLSession); on Android through WorkManager once there is a validated network and the battery is not low. A captive portal counts as offline.
Scans upload one at a time: interrupted ones first, then oldest first. One that fails does not hold up the others. A failure that cannot succeed by retrying (for example a token for the wrong group) is recorded on the scan for your app to show, is not retried for ever, and deletes nothing. Each scan's state is captured, syncing, synced or refined.
Logs then appear on the server as estimates, are refined, and your backend gets the events. The phone checks for refinement for a while after upload; your backend should rely on events, not on the phone.
After the app is killed or the phone restarts#
Nothing accepted is lost. A capture is accepted only after its image and the scan's manifest are on disk, written atomically, so a crash leaves the old state or the new one, never a mix.
When the app opens again, the journal recovers before anything else: it removes half-written files and images that no accepted capture refers to, reports damaged scans without deleting them, and resumes interrupted uploads. Every upload step is safe to repeat, because each scan, log and image carries a client id the API recognises, so a retry after a crash never creates a duplicate, even days later.
When storage is full#
- Android: the phone's free space is checked before each capture is written (a 64 MB reserve is kept). When there is not enough, the capture is refused with "storage full" and is not ticked.
- iOS: the Swift SDK's scanner checks the same 64 MB reserve before each write and says "Phone storage is full. Nothing was saved." A write that fails anyway is not accepted and not ticked.
Retention frees space: image files are deleted 7 days after their upload is confirmed, and a scan 30 days after it is synced. A scan that has not uploaded, and an image whose upload is not confirmed, are never deleted.
When a capture token expires#
Nothing is lost. A capture token lasts at most 24 hours. If it expires, offline or not, capturing carries on; the next upload asks your app for a new token, and on a refusal the scan goes back to waiting with nothing recorded against it. Upload resumes when your app supplies a token (in the Timbereye app's advanced setup: open a new link). An image upload already in progress finishes, since it does not need the token.
Mint tokens that cover at least the longest upload you expect, and have your app's token provider fetch a fresh one from your server when asked. See Capture tokens.