Skip to content

Configuration ​

Configure the Tappd Mobile SDK to match your application's needs.

Configuration Options ​

The SDK accepts a configuration object when initializing:

javascript
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 ​

OptionTypeDefaultRequiredDescription
appIdstring-YesYour App ID from the Tappd dashboard
apiUrlstringhttps://sdk.gotappd.com/api/v1/sdkNoCustom API endpoint URL
autoTrackbooleantrueNoAutomatically track app lifecycle events
sessionTimeoutnumber30NoSession timeout in minutes (inactivity before new session)
enableAutoScreenTrackingbooleantrueNoAutomatically track screen changes (requires manual integration)
enableInAppMessagesbooleantrueNoEnable/disable in-app message rendering
autoDisplayMessagesbooleantrueNoAutomatically fetch and display pending messages
messagePollingIntervalnumber30NoInterval in seconds for polling new messages
debugbooleanfalseNoEnable 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.

javascript
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.

javascript
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 opened
  • app.foreground - When app comes to foreground
  • app.background - When app goes to background
  • app.closed - When app is closed (via cleanup)
javascript
// 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.

javascript
// 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.

javascript
// 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.

javascript
// 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.

javascript
// 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.

javascript
// 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.

javascript
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_123

Environment-Based Configuration ​

Development vs Production ​

javascript
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 ​

javascript
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:

bash
npm install react-native-config

Create .env file:

TAPPD_APP_ID=your_app_id_here
TAPPD_API_URL=https://sdk.gotappd.com/api/v1/sdk

Use in code:

javascript
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 ​

  1. Always use environment variables for App ID in production
  2. Enable debug mode only in development (__DEV__)
  3. Use autoTrack for most applications (simpler setup)
  4. Set appropriate session timeout based on your user behavior patterns
  5. Cleanup SDK when app closes (call cleanup() method)

Next Steps ​

Released under the MIT License.