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
)| Parameter | Description |
|---|---|
context | Any Context. The SDK retains context.applicationContext. |
sdkKey | Project API key. Sent as HTTP header X-API-Key. If empty after trimming, the SDK reads MOTISIG_SDK_KEY from the process environment. |
projectId | Project identifier. Sent as X-Project-ID. If empty, reads MOTISIG_PROJECT_ID. |
baseURL | API base URL (typically ending in /client). If null, reads MOTISIG_BASE_URL; if unset or invalid, falls back to the built-in default. |
logLevel | Minimum level for SDK logging (LogLevel.NONE / ERROR / INFO / DEBUG). |
pingIntervalSeconds | Foreground heartbeat interval. Clamped to 1…86400; non-positive values fall back to 60. |
skipPermissionRequest | Stored for cross-platform config parity; reserved if the SDK adds runtime notification permission prompts. |
skipNotificationListeners | When 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:
| Variable | Maps to |
|---|---|
MOTISIG_SDK_KEY | sdkKey |
MOTISIG_PROJECT_ID | projectId |
MOTISIG_BASE_URL | baseURL |
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 successfulinitialize, even afterreset()(configuration is cleared but the instance object remains). It isnullonly before any successfulinitialize.MotiSig.getInstance().isInitializedistrueafter a successfulinitialize, andfalseafterreset()untilinitializeruns again.MotiSig.getInstance().currentUserIdreflects the persisted user id after a successfulsetUser.MotiSig.getInstance().isNotificationEnabledreflects the customer-controlled push flag (persisted acrosslogout()).
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).