Configuration
Configure the Tappd Mobile SDK to match your application's needs.
Configuration Options
The SDK accepts a configuration object when initializing:
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
apiUrl: 'https://sdk.gotappd.com/api/v1/sdk',
autoTrack: true,
sessionTimeout: 30,
enableAutoScreenTracking: true,
enableInAppMessages: true,
autoDisplayMessages: true,
messagePollingInterval: 30,
debug: false
});Configuration Reference
| Option | Type | Default | Required | Description |
|---|---|---|---|---|
appId | string | - | Yes | Your App ID from the Tappd dashboard |
apiUrl | string | https://sdk.gotappd.com/api/v1/sdk | No | Custom API endpoint URL |
autoTrack | boolean | true | No | Automatically track app lifecycle events |
sessionTimeout | number | 30 | No | Session timeout in minutes (inactivity before new session) |
enableAutoScreenTracking | boolean | true | No | Automatically track screen changes (requires manual integration) |
enableInAppMessages | boolean | true | No | Enable/disable in-app message rendering |
autoDisplayMessages | boolean | true | No | Automatically fetch and display pending messages |
messagePollingInterval | number | 30 | No | Interval in seconds for polling new messages |
debug | boolean | false | No | Enable debug logging to console |
Detailed Options
appId
Your unique App ID from the Tappd dashboard. This identifies your application and is required for all SDK operations.
const tappd = new TappdSDK({
appId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
});apiUrl
Custom API endpoint URL. Only change this if you're using a self-hosted instance or custom domain.
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
apiUrl: 'https://custom-domain.com/api/v1/sdk'
});autoTrack
Enable automatic app lifecycle tracking. When true, the SDK automatically tracks:
app.opened- When app is openedapp.foreground- When app comes to foregroundapp.background- When app goes to backgroundapp.closed- When app is closed (via cleanup)
// Enable auto-tracking (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
autoTrack: true
});
// Disable auto-tracking
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
autoTrack: false
});sessionTimeout
Session timeout in minutes. If the user is inactive for this duration, a new session starts automatically when app comes to foreground.
// 30 minute timeout (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
sessionTimeout: 30
});
// 60 minute timeout
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
sessionTimeout: 60
});enableAutoScreenTracking
Enable automatic screen tracking. Note: This requires manual integration with React Navigation. See React Navigation Guide.
// Enable auto screen tracking (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
enableAutoScreenTracking: true
});enableInAppMessages
Enable or disable in-app message rendering. When enabled, the SDK can fetch and display in-app messages (banners, popups, modals) created in your Tappd dashboard.
// Enable in-app messages (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
enableInAppMessages: true
});
// Disable in-app messages
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
enableInAppMessages: false
});Note: When enabled, you must set up a render callback using setMessageRenderCallback() to display messages in your React Native app.
See also: In-App Messages Guide for detailed documentation.
autoDisplayMessages
Automatically fetch and display pending in-app messages when enabled. Requires enableInAppMessages to be true.
// Auto-display messages (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
enableInAppMessages: true,
autoDisplayMessages: true
});
// Manual message control only
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
enableInAppMessages: true,
autoDisplayMessages: false
});messagePollingInterval
Interval in seconds for polling new messages from the API. Only applies when autoDisplayMessages is enabled.
// Poll every 30 seconds (default)
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
messagePollingInterval: 30
});
// Poll every 60 seconds
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
messagePollingInterval: 60
});debug
Enable debug logging. When true, the SDK logs all operations to the console.
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
debug: true // See all SDK operations in console/logs
});
// Console output:
// [Tappd SDK] Initialized with App ID: a1b2c3d4...
// [Tappd SDK] New session started: sess_abc123
// [Tappd SDK] Event tracked: purchase
// [Tappd SDK] Customer identified: user_123Environment-Based Configuration
Development vs Production
const isDevelopment = __DEV__; // React Native's __DEV__ flag
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
apiUrl: 'https://sdk.gotappd.com/api/v1/sdk',
debug: isDevelopment, // Only debug in development
autoTrack: true,
sessionTimeout: 30
});Multiple Environments
import { Platform } from 'react-native';
const config = {
development: {
appId: 'dev_app_id',
apiUrl: 'https://dev.sdk.gotappd.com/api/v1/sdk',
debug: true
},
staging: {
appId: 'staging_app_id',
apiUrl: 'https://staging.sdk.gotappd.com/api/v1/sdk',
debug: true
},
production: {
appId: 'prod_app_id',
apiUrl: 'https://sdk.gotappd.com/api/v1/sdk',
debug: false
}
};
const env = __DEV__ ? 'development' : 'production';
const tappd = new TappdSDK(config[env]);Using Environment Variables
React Native Config
Install react-native-config:
npm install react-native-configCreate .env file:
TAPPD_APP_ID=your_app_id_here
TAPPD_API_URL=https://sdk.gotappd.com/api/v1/sdkUse in code:
import Config from 'react-native-config';
import TappdSDK from '@tappd/mobile-sdk';
const tappd = new TappdSDK({
appId: Config.TAPPD_APP_ID,
apiUrl: Config.TAPPD_API_URL,
debug: __DEV__
});Best Practices
- Always use environment variables for App ID in production
- Enable debug mode only in development (
__DEV__) - Use autoTrack for most applications (simpler setup)
- Set appropriate session timeout based on your user behavior patterns
- Cleanup SDK when app closes (call
cleanup()method)
Next Steps
- API Reference - Learn about available methods
- Push Notifications - Configure push notifications
- Examples - See configuration in action
