React Native Insider SDK
Official React Native SDK for Insider - A single platform for building individualized, cross-channel customer experiences.

Features
- User Management - Comprehensive user profile management with custom attributes
- Event Tracking - Track custom events with flexible parameters
- E-commerce - Product tracking, cart management, purchase events, and wishlist
- Smart Recommendations - AI-powered personalized product recommendations
- Message Center - In-app messaging and notification management
- Content Optimizer - A/B testing and dynamic content optimization
- Push Notifications - Rich push notifications with deep linking support
- In-App Messages - Native in-app messaging with callback handlers
- Geofencing - Location-based targeting and triggers
- GDPR Compliance - Built-in consent management and privacy controls
- TypeScript Support - Full TypeScript definitions included
Installation
With npm:
npm install react-native-insider
With yarn:
yarn add react-native-insider
iOS
- Install CocoaPods dependencies:
cd ios && pod install && cd ..
-
In your Xcode project, enable the following capabilities under Signing & Capabilities:
- Push Notifications (if you are using InsiderMobileAdvancedNotification SDK)
- Location (Always and WhenInUse) (if you are using InsiderGeofence SDK)
- Background Modes:
Remote notifications and Location updates
-
For rich push notifications, add Notification Service Extension and Notification Content Extension targets to your iOS project. Add the following to your Podfile:
target 'YourNotificationService' do
use_frameworks!
pod "InsiderMobileAdvancedNotification"
end
target 'YourNotificationContent' do
use_frameworks!
pod "InsiderMobileAdvancedNotification"
end
Android Setup
- Add the Insider Maven repository to your project-level
android/build.gradle:
allprojects {
repositories {
maven { url 'https://mobilesdk.useinsider.com/android' }
}
}
- Add Google Services to your project-level
android/build.gradle:
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.4'
}
}
- In your app-level
android/app/build.gradle, add your partner name:
android {
defaultConfig {
manifestPlaceholders = [partner: 'your_partner_name']
}
}
- If
android:allowBackup="false" exists in your AndroidManifest.xml, remove it to allow Insider SDK to function properly.
Quick Start
import React, { useEffect } from 'react';
import Insider from 'react-native-insider';
import InsiderCallbackType from 'react-native-insider/src/InsiderCallbackType';
function App() {
useEffect(() => {
Insider.init(
'your_partner_name',
'group.com.your.app',
(type, data) => {
switch(type) {
case InsiderCallbackType.NOTIFICATION_OPEN:
console.log('Notification opened:', data);
break;
case InsiderCallbackType.INAPP_BUTTON_CLICK:
console.log('In-app button clicked:', data);
break;
case InsiderCallbackType.SESSION_STARTED:
console.log('Session started');
break;
}
}
);
Insider.registerWithQuietPermission(false);
Insider.setActiveForegroundPushView();
Insider.enableIDFACollection(true);
Insider.enableLocationCollection(true);
Insider.startTrackingGeofence();
}, []);
return <YourApp />;
}
API Reference
Initialization
init(partnerName, appGroup, callback)
Initialize the Insider SDK with your partner name and callback handler.
Insider.init(
'your_partner_name',
'group.com.your.app',
(type, data) => {
}
);
Parameters:
partnerName (string): Your Insider partner name
appGroup (string): iOS App Group ID (e.g., 'group.com.your.app')
callback (function): Callback function to handle SDK events
initWithCustomEndpoint(partnerName, appGroup, endpoint, callback)
Initialize with a custom API endpoint for enterprise customers.
Insider.initWithCustomEndpoint(
'your_partner_name',
'group.com.your.app',
'https://your-custom-endpoint.com',
(type, data) => {
}
);
User Management
Get Current User
const user = Insider.getCurrentUser();
User Attributes
import InsiderGender from 'react-native-insider/src/InsiderGender';
user
.setName('John')
.setSurname('Doe')
.setAge(30)
.setGender(InsiderGender.Male)
.setBirthday(new Date('1990-01-01'))
.setEmail('john.doe@example.com')
.setPhoneNumber('+1234567890')
.setLanguage('en')
.setLocale('en_US');
Marketing Preferences
user
.setEmailOptin(true)
.setSMSOptin(true)
.setPushOptin(true)
.setWhatsappOptin(true)
.setLocationOptin(true);
Custom Attributes
user
.setCustomAttributeWithString('membership_level', 'gold')
.setCustomAttributeWithInt('loyalty_points', 1500)
.setCustomAttributeWithDouble('account_balance', 99.99)
.setCustomAttributeWithBoolean('is_premium', true)
.setCustomAttributeWithDate('last_purchase', new Date())
.setCustomAttributeWithArray('interests', ['sports', 'technology']);
user.unsetCustomAttribute('membership_level');
Login/Logout
import InsiderIdentifier from 'react-native-insider/src/InsiderIdentifier';
const identifiers = new InsiderIdentifier()
.addEmail('user@example.com')
.addPhoneNumber('+1234567890')
.addUserID('user123')
.addCustomIdentifier('custom_key', 'custom_value');
user.login(identifiers);
user.login(identifiers, (insiderID) => {
console.log('Insider ID:', insiderID);
});
user.logout();
Insider.signUpConfirmation();
Event Tracking
Insider.tagEvent('app_opened').build();
Insider.tagEvent('product_viewed')
.addParameterWithString('product_id', 'SKU123')
.addParameterWithString('category', 'Electronics')
.addParameterWithDouble('price', 299.99)
.addParameterWithInt('quantity', 1)
.addParameterWithBoolean('in_stock', true)
.addParameterWithDate('viewed_at', new Date())
.addParameterWithArray('tags', ['featured', 'sale'])
.addParameterWithStringArray('colors', ['red', 'blue'])
.addParameterWithNumericArray('ratings', [4.5, 5.0])
.build();
Product & E-commerce
Create a Product
const product = Insider.createNewProduct(
'product_id',
'Product Name',
['Category', 'Subcategory'],
'https://example.com/image.jpg',
99.99,
'USD'
);
product
.setColor('Blue')
.setSize('M')
.setBrand('BrandName')
.setSalePrice(79.99)
.setStock(100)
.setQuantity(1)
.setSku('SKU-123')
.setVoucherName('SUMMER2024')
.setVoucherDiscount(20)
.setPromotionName('Summer Sale')
.setPromotionDiscount(15)
.setShippingCost(5.99)
.setGender('Unisex')
.setDescription('Product description')
.setTags(['featured', 'bestseller'])
.setInStock(true);
Cart Operations
Insider.itemAddedToCart(product);
Insider.itemRemovedFromCart('product_id');
Insider.cartCleared();
Wishlist Operations
Insider.itemAddedToWishlist(product);
Insider.itemRemovedFromWishlist('product_id');
Insider.wishlistCleared();
Purchase
Insider.itemPurchased('unique_sale_id_12345', product);
Page Visits
Insider.visitHomePage();
Insider.visitListingPage(['Category', 'Subcategory']);
Insider.visitProductDetailPage(product);
Insider.visitCartPage([product1, product2]);
Insider.visitWishlistPage([product1, product2]);
Smart Recommendations
Insider.getSmartRecommendation(
12345,
'en_US',
'USD',
(recommendation) => {
console.log('Recommendations:', recommendation);
}
);
Insider.getSmartRecommendationWithProduct(
product,
12345,
'en_US',
(recommendation) => {
console.log('Related products:', recommendation);
}
);
Insider.getSmartRecommendationWithProductIDs(
['prod1', 'prod2'],
12345,
'en_US',
'USD',
(recommendation) => {
console.log('Recommendations:', recommendation);
}
);
Insider.clickSmartRecommendationProduct(12345, product);
Message Center
Insider.getMessageCenterData(
20,
new Date('2024-01-01'),
new Date(),
(messages) => {
console.log('Messages:', messages);
}
);
Content Optimizer
import ContentOptimizerDataType from 'react-native-insider/src/ContentOptimizerDataType';
Insider.getContentStringWithName(
'variable_name',
'default_value',
ContentOptimizerDataType.Content,
(value) => {
console.log('Content:', value);
}
);
Insider.getContentBoolWithName(
'feature_enabled',
false,
ContentOptimizerDataType.Element,
(value) => {
console.log('Feature enabled:', value);
}
);
Insider.getContentIntWithName(
'max_items',
10,
ContentOptimizerDataType.Content,
(value) => {
console.log('Max items:', value);
}
);
Insider.getContentStringWithoutCache(
'variable_name',
'default',
ContentOptimizerDataType.Content,
(value) => {
console.log('Fresh content:', value);
}
);
Push Notifications
iOS Configuration
Insider.registerWithQuietPermission(true);
Insider.setForegroundPushCallback((notification) => {
console.log('Foreground push:', notification);
});
Insider.setActiveForegroundPushView();
Insider.enableIDFACollection(true);
Insider.disableTemplatesForIOS();
Insider.reenableTemplatesForIOS();
Android Configuration
Insider.setHybridPushToken('your_fcm_token');
Insider.handleUniversalLink('https://your-link.com/path');
General Push Methods
Insider.handleNotification(notificationData);
In-App Messages
Insider.removeInapp();
Insider.disableInAppMessages();
Insider.enableInAppMessages();
Geofencing
Insider.startTrackingGeofence();
Insider.setAllowsBackgroundLocationUpdates(true);
GDPR & Privacy
Insider.setGDPRConsent(true);
Insider.setMobileAppAccess(true);
Insider.enableLocationCollection(true);
Insider.enableIpCollection(true);
Insider.enableCarrierCollection(true);
Insider ID
const insiderID = await Insider.getInsiderID();
console.log('Insider ID:', insiderID);
Insider.insiderIDListener((insiderID) => {
console.log('Insider ID updated:', insiderID);
});
Miscellaneous
Insider.showNativeAppReview();
Insider.reinitWithPartnerName('new_partner_name');
TypeScript Support
The SDK includes full TypeScript definitions:
import Insider from 'react-native-insider';
import InsiderGender from 'react-native-insider/src/InsiderGender';
import InsiderIdentifier from 'react-native-insider/src/InsiderIdentifier';
import InsiderCallbackType from 'react-native-insider/src/InsiderCallbackType';
import ContentOptimizerDataType from 'react-native-insider/src/ContentOptimizerDataType';
Enums
InsiderGender
InsiderGender.Male
InsiderGender.Female
InsiderGender.Other
InsiderCallbackType
InsiderCallbackType.NOTIFICATION_OPEN
InsiderCallbackType.INAPP_BUTTON_CLICK
InsiderCallbackType.TEMP_STORE_PURCHASE
InsiderCallbackType.TEMP_STORE_ADDED_TO_CART
InsiderCallbackType.TEMP_STORE_CUSTOM_ACTION
InsiderCallbackType.INAPP_SEEN
InsiderCallbackType.SESSION_STARTED
ContentOptimizerDataType
ContentOptimizerDataType.Content
ContentOptimizerDataType.Element
Complete Example
import React, { useEffect } from 'react';
import { Platform, Linking } from 'react-native';
import Insider from 'react-native-insider';
import InsiderGender from 'react-native-insider/src/InsiderGender';
import InsiderIdentifier from 'react-native-insider/src/InsiderIdentifier';
import InsiderCallbackType from 'react-native-insider/src/InsiderCallbackType';
function App() {
useEffect(() => {
Insider.init('your_partner_name', 'group.com.your.app', (type, data) => {
switch(type) {
case InsiderCallbackType.NOTIFICATION_OPEN:
console.log('Notification clicked:', data);
break;
case InsiderCallbackType.INAPP_BUTTON_CLICK:
console.log('In-app button clicked:', data);
break;
case InsiderCallbackType.SESSION_STARTED:
console.log('Session started');
break;
}
});
Insider.registerWithQuietPermission(false);
Insider.setActiveForegroundPushView();
Insider.startTrackingGeofence();
Insider.enableIDFACollection(true);
Insider.enableLocationCollection(true);
if (Platform.OS === 'android') {
Linking.getInitialURL().then((url) => {
if (url) {
Insider.handleUniversalLink(url);
}
});
const urlListener = Linking.addEventListener('url', (event) => {
Insider.handleUniversalLink(event.url);
});
return () => urlListener.remove();
}
const user = Insider.getCurrentUser();
user
.setName('Jane')
.setEmail('jane@example.com')
.setAge(25)
.setGender(InsiderGender.Female);
const identifiers = new InsiderIdentifier()
.addEmail('jane@example.com')
.addUserID('user_123');
user.login(identifiers);
Insider.visitHomePage();
Insider.tagEvent('app_opened')
.addParameterWithString('source', 'direct')
.addParameterWithDate('timestamp', new Date())
.build();
const product = Insider.createNewProduct(
'SKU001',
'Premium T-Shirt',
['Clothing', 'T-Shirts'],
'https://example.com/tshirt.jpg',
29.99,
'USD'
);
product.setColor('Blue').setSize('M');
Insider.visitProductDetailPage(product);
}, []);
return <YourApp />;
}
Requirements
- React Native >= 0.60
- iOS >= 11.0
- Android >= API 21 (Android 5.0)
Support
License
This SDK is provided by Insider. Please refer to your commercial agreement with Insider for licensing terms.