nbase-ad-react-native-sdk
v1.0.2
Published
React Native SDK for AdStage
Readme
NBase AdStage React Native SDK
React Native SDK for NBase AdStage - Deep link and promotion management solution.
Installation
npm install nbase-ad-react-native-sdk
# or
yarn add nbase-ad-react-native-sdkPlatform Setup
iOS Setup
- Install iOS dependencies:
cd ios && pod install- Add to your
ios/Podfile:
pod 'AdapterAdStage', '3.0.2'Android Setup
- Add to your
android/build.gradle(project level):
allprojects {
repositories {
// ... other repositories
maven { url "https://repo.nbase.io/repository/nbase-releases" }
}
}- The SDK automatically includes the required dependencies.
Usage
Basic Setup
import AdStageSDK from 'nbase-ad-react-native-sdk';
// Initialize the SDK using AdStageSDK unified class
await AdStageSDK.setApiKey('YOUR_API_KEY');
// Optional: Set server URL
await AdStageSDK.setServerUrl('https://beta-api.adstage.app');Deep Link Handling
// Setup unified deep link listener (uses AdStageSDK.setUnifiedListener internally)
AdStageSDK.setUnifiedListener((event) => {
console.log('Deep link received:', event.deepLink);
console.log('Payload:', event.payload);
});
// Or use the automatic setup with options
AdStageSDK.setupDeepLinkHandling((event) => {
console.log('Deep link received:', event.deepLink);
console.log('Payload:', event.payload);
}, {
autoCheckPending: true, // Check for pending deep links on app start
autoHandleAppState: true, // Handle app foreground events
showAlert: false // Show alert when deep link received
});Create Deep Links
// Using the unified AdStageSDK approach
const deepLinkConfig = {
name: 'My Campaign',
description: 'Campaign description',
shortPath: 'promo2024',
channel: 'social',
campaign: 'summer_sale',
parameters: {
product_id: '123',
discount: '20'
}
};
// Create deep link using AdStageSDK
const shortUrl = await AdStageSDK.createDeepLink().create(deepLinkConfig);
console.log('Generated URL:', shortUrl);Promotion Management
// Get promotion list using AdStageSDK.PromotionParams
const promotionParams = {
bannerType: 'POPUP', // NATIVE, INTERSTITIAL, REWARDED_VIDEO, POPUP
targetAudience: 'new_users', // Custom target audience
deviceType: 'HIGH_END', // LOW_END, MID_END, HIGH_END
region: 'KR', // KR, JP, US, SEA, EU, GLOBAL
limit: 10, // Number of promotions to fetch
status: 'ACTIVE', // ACTIVE, PENDING, PAUSED, ENDED
partner: 'partner_name', // Partner/advertiser filter
primaryInterest: 'GAMES', // GAMES, SHOPPING, ENTERTAINMENT, etc.
primaryAgeGroup: '18-24', // 13-17, 18-24, 25-34, 35-44, 45+
gameGenrePreference: 'RPG', // RPG, STRATEGY, CASUAL, ACTION, PUZZLE
playerSpendingTier: 'WHALE', // F2P, DOLPHIN, WHALE
playTimePattern: 'EVENING' // MORNING, AFTERNOON, EVENING, NIGHT
};
// Get promotion list using AdStageSDK
const promotions = await AdStageSDK.getPromotionList(promotionParams);
console.log('Promotions:', promotions);
// Open promotion dialog using AdStageSDK
await AdStageSDK.openPromotion(promotionParams, true); // showTodayButtonEvent Tracking
// Track custom events
await AdStageSDK.trackEvent('user_action', {
deeplinkId: 'abc123',
action_type: 'click',
value: 100
});User Management
// Set user ID
await AdStageSDK.setUserId('user_12345');
// Get user ID
const userId = await AdStageSDK.getUserId();
// Set custom attributes
await AdStageSDK.setCustomAttribute('user_level', '5');
// Get all attributes
const attributes = await AdStageSDK.getAllCustomAttributes();API Reference
Methods
initialize(apiKey: string): Promise<void>setupDeepLinkHandling(callback, options?): voidcreateDeepLink(config: DeepLinkConfig): Promise<string>getPromotionList(params: PromotionParams): Promise<PromotionListResult>openPromotion(params: PromotionParams, showTodayButton?: boolean): Promise<string>trackEvent(eventName: string, params?: EventParams): Promise<void>setUserId(userId: string): Promise<void>getUserId(): Promise<string>setCustomAttribute(key: string, value: string): Promise<void>getAllCustomAttributes(): Promise<Record<string, string>>
Interfaces
interface DeepLinkConfig {
name: string;
description?: string;
shortPath?: string;
channel?: string;
campaign?: string;
parameters?: Record<string, string>;
}
interface PromotionParams {
promotionId?: string;
bannerType?: string;
targetAudience?: string;
limit?: number;
status?: string;
showTodayButton?: boolean;
}Requirements
- React Native >= 0.60
- iOS >= 15.0
- Android API Level >= 24
License
MIT
Support
For support, please visit NBase.io
