Skip to main content
SDKsAndroid

Configuration

MotiSig.initialize, reset, env vars, and runtime state for the Android SDK.

MotiSig.initialize

Call once at process start (typically Application.onCreate):

val ok = MotiSig.initialize(
    context = this,
    sdkKey = "your-sdk-key",
    projectId = "your-project-id",
    baseURL = null,                // optional; see default below
    logLevel = LogLevel.ERROR,     // NONE, ERROR, INFO, DEBUG
    pingIntervalSeconds = 60,      // 1…86400, defaults to 60
    skipPermissionRequest = false, // reserved for future runtime permission parity
    skipNotificationListeners = false, // when true, MotiSigFirebaseMessagingService does not auto-dispatch to listeners
)
ParameterDescription
contextAny Context. The SDK retains context.applicationContext.
sdkKeyProject API key. Sent as HTTP header X-API-Key. If empty after trimming, the SDK reads MOTISIG_SDK_KEY from the process environment.
projectIdProject identifier. Sent as X-Project-ID. If empty, reads MOTISIG_PROJECT_ID.
baseURLAPI base URL (typically ending in /client). If null, reads MOTISIG_BASE_URL; if unset or invalid, falls back to the built-in default.
logLevelMinimum level for SDK logging (LogLevel.NONE / ERROR / INFO / DEBUG).
pingIntervalSecondsForeground heartbeat interval. Clamped to 1…86400; non-positive values fall back to 60.
skipPermissionRequestStored for cross-platform config parity; reserved if the SDK adds runtime notification permission prompts.
skipNotificationListenersWhen true, the default FCM service does not call listeners or buffer (iOS skipNotificationListeners parity). You can still forward pushes manually via MotiSig.handleNotificationReceived.

Returns true when the SDK is configured, or when initialize is called again while already initialized (idempotent). Returns false if sdkKey or projectId resolves to empty (no HTTP client; MotiSig.tryGetInstance() may still be non-null after a prior successful init).

MotiSig.reset

Clears local SDK state without calling server logout (same contract as iOS). Use before calling initialize again with new credentials. The singleton instance remains; isInitialized becomes false until the next successful initialize.

MotiSigAPIClient

HTTP-only client with the same headers as the singleton (getUser, trackClick, ping with transport retry on ping). See MotiSigAPIClient.kt in the SDK repository.

onFcmTokenChange

After initialize, assign MotiSig.getInstance().onFcmTokenChange = { newToken, previous -> … } to mirror iOS onApnsTokenChange when the FCM registration token changes.

Default base URL

When no valid baseURL or MOTISIG_BASE_URL is provided, the SDK uses:

https://api.motisig.ai/client

(Defined in Configuration.defaultBaseURL.)

Environment variables

You can rely entirely on the process environment:

VariableMaps to
MOTISIG_SDK_KEYsdkKey
MOTISIG_PROJECT_IDprojectId
MOTISIG_BASE_URLbaseURL

The example app injects them into BuildConfig via a .env.local file; see examples/motisig-android-example for the Gradle wiring. Never commit real keys.

Runtime state

  • MotiSig.tryGetInstance() returns the singleton instance after the first successful initialize, even after reset() (configuration is cleared but the instance object remains). It is null only before any successful initialize.
  • MotiSig.getInstance().isInitialized is true after a successful initialize, and false after reset() until initialize runs again.
  • MotiSig.getInstance().currentUserId reflects the persisted user id after a successful setUser.
  • MotiSig.getInstance().isNotificationEnabled reflects the customer-controlled push flag (persisted across logout()).

Log level

Logger writes to android.util.Log at the requested severity:

  • NONE — silent.
  • ERROR — errors only (recommended for release builds).
  • INFO — lifecycle events (MotiSig initialized, setUser completed, etc.).
  • DEBUG — verbose, including dropped events and skipped click tracking.

After reset(), call initialize again to change logLevel or other configuration. While already initialized, a second initialize returns true without applying new parameters (first successful init wins, matching iOS).