init()
Initialize the Mobana SDK. Must be called before any other SDK methods.
Method Signature#
Mobana.init(config: MobanaConfig): Promise<void>Usage#
App.tsx
import { Mobana } from '@mobana/react-native-sdk';
// Initialize once on app start
// (no need to await — attribution starts in the background)
Mobana.init({
appId: 'a1b2c3d4',
appKey: 'your-32-char-hex-app-key-from-dashboard',
});Parameters#
| Parameter | Type | Description |
|---|---|---|
appIdRequired | string | Your Mobana app ID from the Dashboard (e.g., a1b2c3d4). |
appKeyRequired | string | Your Mobana app key from the Dashboard. Sent as X-App-Key header. Regenerate from app settings if leaked. |
endpoint | string | Custom API endpoint URL. Use this when proxying through your own domain. Default: https://{appId}.mobana.ai |
enableTracking | boolean= true | Enable or disable attribution and tracking. Set to false to disable tracking (useful for GDPR opt-out). Flows (startFlow, prefetchFlow) are unaffected and work regardless. |
autoAttribute | boolean= true | Fetch attribution automatically in the background when init() is called. The result is cached so getAttribution() returns instantly. Set to false to delay attribution until you explicitly call getAttribution()(e.g., to wait for GDPR consent before any network activity). |
debug | boolean= false | Enable debug logging. Useful during development to see SDK operations in the console. |
Full Example#
App.tsx
Mobana.init({
// Required: Your app ID from the Mobana Dashboard
appId: 'a1b2c3d4',
// Required: Your app key (sent as X-App-Key). Regenerate from dashboard if leaked.
appKey: 'your-32-char-hex-app-key-from-dashboard',
// Optional: Custom endpoint for domain proxying
// Default: https://{appId}.mobana.ai
endpoint: 'https://myapp.com/d',
// Optional: Enable/disable attribution and tracking (default: true)
// Set to false to disable tracking (e.g., GDPR opt-out). Flows still work when false.
enableTracking: true,
// Optional: Fetch attribution automatically on init (default: true)
// Set to false to delay until you explicitly call getAttribution()
autoAttribute: true,
// Optional: Enable debug logging (default: false)
debug: __DEV__,
});Usage Patterns#
App.tsx
// Awaiting init is optional — only needed if you require attribution data
// before rendering anything (e.g., campaign-specific onboarding).
await Mobana.init({ appId: 'a1b2c3d4', appKey: 'your-app-key' });
const { status, attribution } = await Mobana.getAttribution();
// For GDPR: delay attribution until the user consents
Mobana.init({ appId: 'a1b2c3d4', appKey: 'your-app-key', autoAttribute: false });
// ... show consent UI ...
const { attribution } = await Mobana.getAttribution(); // attribution fetched here, unless SDK was disabledBehavior#
- Auto-attribution: By default, attribution is fetched in the background the moment
init()is called — non-blocking. When you later callgetAttribution(), the result is already cached and returns instantly. ConcurrentgetAttribution()requests return same Promise, so you do not need to worry about the ordering. - Queued conversions: Any conversions tracked before initialization are queued and sent after
init()completes. - Idempotent: Calling
init()multiple times is safe. Subsequent calls update the configuration. - Required first: Other SDK methods like getAttribution() and startFlow() require initialization.
Where to call init()
Call init() as early as possible in your app lifecycle — you generally don't need to await it. Good places include:
- Your root App component (before rendering your navigation container)
- In your app's entry point file
AI agents: for complete Mobana SDK & API documentation, get full context here or visit llms.txt