Authentication
The second argument of initAndStartTracking(), skipLoginAndRegistration, selects how the SDK
authenticates against your tracking backend.
| Mode | skipLoginAndRegistration | callerAccessToken | BuildConfig fields that must be nonblank |
|---|---|---|---|
| A - SDK-managed | false | null | All six |
| B - Caller-provided token | true | Required | TRACKING_BASE_URL, TRACKING_SERVER_URL, TRACKING_TENANT_NAME |
See Get Started - Configure the tracking backend for the full field list.
Mode A: SDK-managed login and registration
import {initAndStartTracking} from './src/TrackingSdk';
await initAndStartTracking('driver-001', false, null, 50);
Configure all six backend fields. The bridge asks the SDK to run its login and registration flow, then starts tracking only after initialization succeeds.
Mode B: caller-provided access token
import {initAndStartTracking} from './src/TrackingSdk';
export async function startWithSession(username: string, accessToken: string) {
return initAndStartTracking(username, true, accessToken, 50);
}
Pass a valid token from your application's own authentication flow - for example one obtained from the Authentication API. The SDK is told to skip login and registration, so complete any required registration beforehand. Token format, expiry and renewal must match your backend contract.
The Android bridge does not expose a token replacement or refresh method. Agree on a supported renewal flow before relying on long-running caller-managed sessions.
Initialization result
A successful initialization resolves to:
{
success: true,
message: 'Tracking started successfully',
accessToken: '...',
skipLoginAndRegistration: false,
username: 'driver-001',
distanceFilter: 50,
}
The result object contains an access token. Avoid logging it.
A duplicate initialization while another is still running resolves with only success and an
"already in progress" message - that response does not confirm startup completed. Serialize your
start and stop actions and check the current state with getTrackingState().
See also: Usage.