Skip to main content
SDKsExpo

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.

OptionDefaultDescription
sdkKeyrequiredProject API key. Sent as HTTP header X-API-Key.
projectIdrequiredProject identifier. Sent as X-Project-ID.
baseURLresolved per resolveClientBaseUrlAPI base URL. Falls back to DEFAULT_MOTISIG_BASE_URL (https://api.motisig.ai/client).
easProjectIdConstants.expoConfig?.extra?.eas?.projectIdEAS project UUID required by Notifications.getExpoPushTokenAsync.
skipPermissionRequestfalseWhen true, skip requestNotificationPermissions() during init.
skipNotificationListenersfalseWhen true, do not attach expo-notifications listeners. The SDK then runs HTTP-only.
pingIntervalSeconds60Foreground heartbeat interval. Clamped to 1…86400; non-finite or non-positive values fall back to 60.
clickRetrysee belowOptions for persisted click-queue retries (exponential backoff).
clickRetry.maxAttempts50Maximum send attempts per queued click.
clickRetry.baseDelayMs1000Base delay for exponential backoff in milliseconds.
clickRetry.maxDelayMs60000Maximum backoff delay in milliseconds.

EAS project id

Expo push tokens require an EAS project id. The SDK resolves it from, in order:

  1. options.easProjectId
  2. Constants.expoConfig?.extra?.eas?.projectId (read from app.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.isInitializedtrue after a successful initialize.
  • motisig.currentUserId — current user id (after setUser), or null.
  • motisig.isNotificationEnabled — current customer-controlled push flag (persisted with @react-native-async-storage/async-storage when 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.