Configuration
Initialize options, base URL, EAS project id, env vars, and lower-level clients for @motisig/expo-motisig-sdk.
MotiSig#initialize
Call once after constructing the client:
const motisig = new MotiSig();
await motisig.initialize({
sdkKey: 'your-sdk-key',
projectId: 'your-project-id',
baseURL: 'https://api.motisig.ai/client', // optional
easProjectId: 'uuid', // optional
skipPermissionRequest: false, // optional
skipNotificationListeners: false, // optional
pingIntervalSeconds: 60, // optional
clickRetry: {
maxAttempts: 50, // optional; default 50
baseDelayMs: 1000, // optional; default 1000
maxDelayMs: 60000, // optional; default 60000
},
});initialize returns Promise<boolean> — false only if sdkKey or projectId resolved to an empty string after trimming. Subsequent calls are no-ops once the instance is initialized.
| Option | Default | Description |
|---|---|---|
sdkKey | required | Project API key. Sent as HTTP header X-API-Key. |
projectId | required | Project identifier. Sent as X-Project-ID. |
baseURL | resolved per resolveClientBaseUrl | API base URL. Falls back to DEFAULT_MOTISIG_BASE_URL (https://api.motisig.ai/client). |
easProjectId | Constants.expoConfig?.extra?.eas?.projectId | EAS project UUID required by Notifications.getExpoPushTokenAsync. |
skipPermissionRequest | false | When true, skip requestNotificationPermissions() during init. |
skipNotificationListeners | false | When true, do not attach expo-notifications listeners. The SDK then runs HTTP-only. |
pingIntervalSeconds | 60 | Foreground heartbeat interval. Clamped to 1…86400; non-finite or non-positive values fall back to 60. |
clickRetry | see below | Options for persisted click-queue retries (exponential backoff). |
clickRetry.maxAttempts | 50 | Maximum send attempts per queued click. |
clickRetry.baseDelayMs | 1000 | Base delay for exponential backoff in milliseconds. |
clickRetry.maxDelayMs | 60000 | Maximum backoff delay in milliseconds. |
EAS project id
Expo push tokens require an EAS project id. The SDK resolves it from, in order:
options.easProjectIdConstants.expoConfig?.extra?.eas?.projectId(read fromapp.json/app.config.*)
If neither is available, motisig.getExpoPushToken() returns null and no push subscription is uploaded — the rest of the SDK still works (REST + listener emitter).
The included Expo config plugin (app.plugin.js in the SDK repo) warns at prebuild time if the EAS project id is missing.
Default base URL
DEFAULT_MOTISIG_BASE_URL exported from the package: https://api.motisig.ai/client.
Environment variables
The Expo bundler does not inject arbitrary env vars; use Expo's EXPO_PUBLIC_* convention so they are available at runtime:
EXPO_PUBLIC_MOTISIG_SDK_KEY=...
EXPO_PUBLIC_MOTISIG_PROJECT_ID=...await motisig.initialize({
sdkKey: process.env.EXPO_PUBLIC_MOTISIG_SDK_KEY!,
projectId: process.env.EXPO_PUBLIC_MOTISIG_PROJECT_ID!,
});The example app demonstrates the wiring; see .env.example in motisig-expo-example.
Runtime state
motisig.isInitialized—trueafter a successfulinitialize.motisig.currentUserId— current user id (aftersetUser), ornull.motisig.isNotificationEnabled— current customer-controlled push flag (persisted with@react-native-async-storage/async-storagewhen installed).
Customer push preference
The customer-enabled flag is loaded from AsyncStorage (when present) at init time. If AsyncStorage is not installed in the host app, the value defaults to true and is held in-memory only.
Click queue
Notification opens and trackClick calls are queued on disk when @react-native-async-storage/async-storage is installed in the host app. Without it, the queue and persisted user id use an in-memory fallback for the current process only (clicks are lost on kill/relaunch).
The SDK retries failed POST /track/click requests with exponential backoff for transient errors (network failure, 408, 429, 5xx). Non-retryable 4xx responses are dropped with a warning. Tune behavior with clickRetry on initialize.
logout() and reset() clear the pending click queue and dedupe store. reset() also tears down listeners and init state.
Lower-level clients
If you only need REST without notifications, use createMotiSigApi:
import { createMotiSigApi } from '@motisig/expo-motisig-sdk';
const api = createMotiSigApi({
baseUrl: 'https://api.motisig.ai/client',
sdkKey: '...',
projectId: '...',
});MotiSigHttpClient is also exported for fully custom transports.