Mappls InTouch

Browser SDK

Import InTouch, captureSensors, captureClip, publishPreview or liveSocket from /sdk/intouch.js. Use the same origin for the sample or proxy the API under your application's origin. HTTPS and permission gestures are required on physical devices. Tokens supplied to the SDK should be device-scoped. Credentials stay in memory. The origin and a token digest scope the local IndexedDB. Rotating a credential requires a planned drain of its existing outbox.

const client = await InTouch.open({token: deviceToken, onStatus: showStatus});
const stopSensors = await captureSensors(client, {location:true, motion:true});
client.start();
await client.recordBurst([{ts:Date.now(),kind:"temperature",values:{celsius:4.8}}],"manual");
await client.flush();
await stopSensors();
client.stop();

Foreground sensors buffer briefly before local commit. The browser adapter coalesces small sensor groups into bounded envelopes. Standalone recordBurst calls preserve their own ID. Each batch has up to 256 samples or 64 KiB, with at most 256 total persisted outbox items and four clips of up to 16 MiB. When saturated, enqueue rejects and the adapter reports a status message. Closing a page before local commit can lose pending readings. Browser storage eviction, OS suspension and sensor availability vary by platform. A heartbeat reconciles desired settings and applies flush controls. Network failures retain queued data. Storage dispatch preserves the sealed payload and ID until matching acknowledgement.

On a user gesture, call await client.queueClip(await captureClip(3)) followed by flush. For low-bandwidth live video, call const stop = await publishPreview(client, deviceID, onClose), then stop() to switch off the camera. The live path keeps one JPEG in memory per active publisher. The viewer receives no recording of this stream. Use explicit clip upload for retention. A live viewer opens liveSocket(location.origin, "watch", deviceID, viewerToken) and handles binary messages. Device-wide viewer credentials belong only in a trusted operator session.