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
await Mobana.init({
appId: 'a1b2c3d4',
});Parameters#
| Parameter | Type | Description |
|---|---|---|
appIdRequired | string | Your Mobana app ID from the Dashboard (e.g., a1b2c3d4). |
endpoint | string | Custom API endpoint URL. Use this when proxying through your own domain. Default: https://{appId}.mobana.ai |
enabled | boolean= true | Enable or disable the SDK. Set to false to disable all tracking (useful for GDPR opt-out). |
debug | boolean= false | Enable debug logging. Useful during development to see SDK operations in the console. |
Full Example#
App.tsx
await Mobana.init({
// Required: Your app ID from the Mobana Dashboard
appId: 'a1b2c3d4',
// Optional: Custom endpoint for domain proxying
// Default: https://{appId}.mobana.ai
endpoint: 'https://myapp.com/d',
// Optional: Enable/disable SDK (default: true)
// Set to false to disable all tracking (e.g., GDPR opt-out)
enabled: true,
// Optional: Enable debug logging (default: false)
debug: __DEV__,
});Error Handling#
The init() method returns a Promise that resolves when initialization is complete. If initialization fails (e.g., invalid app ID), the Promise will reject.
App.tsx
try {
await Mobana.init({ appId: 'a1b2c3d4' });
console.log('SDK initialized successfully');
} catch (error) {
console.error('Failed to initialize SDK:', error);
}Behavior#
- 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. Good places include:
- Your root App component (inside useEffect)
- Before rendering your navigation container
- In your app's entry point