Configuration
This guide explains how to initialize and configure the Empower Mobile Ads SDK in your React Native application.
SDK Initialization
Initialize the SDK as early as possible in your application lifecycle — ideally in your root App component.
Basic Initialization
import { useEffect } from 'react';import { Platform } from 'react-native';import { init } from '@empower-nokta/react-native-mobile-ads';export default function App() {useEffect(() => {const appId = Platform.select({android: 'your_android_app_identifier',ios: 'your_ios_app_identifier',});init({ appAdIdentifier: appId });}, []);return (// Your app content);}
Important: Replace the identifiers with the app identifiers provided by Empower.
Initialization with Options
import { init } from '@empower-nokta/react-native-mobile-ads';init({appAdIdentifier: 'your_app_identifier',debugMode: false, // Enable debug logging (disable in production)logLevel: 'default', // Log verbosity levelnonPersonalizedAds: false, // GDPR: non-personalized ads onlyvariant: 'A', // Optional: A/B test variant});
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
appAdIdentifier | string | — | Required. Your app identifier from Empower. |
debugMode | boolean | false | Enables verbose logging and test ads. Disable in production. |
logLevel | string | 'none' | Controls the verbosity of SDK logs. |
nonPersonalizedAds | boolean | false | When true, serves only non-personalized ads (GDPR compliance). |
variant | string | undefined | Optional A/B test variant string. |
Log Levels
| Level | Description |
|---|---|
'all' | Logs all messages including debug information |
'default' | Logs general information and errors |
'warning' | Logs warnings and errors only |
'error' | Logs errors only |
'none' | Disables all logging |
Listening for SDK Ready State (Optional)
If you need to know exactly when the SDK is ready (for analytics, UI updates, etc.), use the event listener:
import { addEventListener, EmpowerAdsEvents } from '@empower-nokta/react-native-mobile-ads';const unsubscribe = addEventListener(EmpowerAdsEvents.SDK_READY, () => {console.log('Empower SDK is ready');});const unsubscribeFailed = addEventListener(EmpowerAdsEvents.SDK_FAILED, (error) => {console.log('Empower SDK initialization failed', error);});// Clean up when no longer neededunsubscribe();unsubscribeFailed();
Note: This listener is optional. Since all ad types automatically queue, you don't need to wait for SDK ready before loading ads.
Automatic Ad Queueing
All ads automatically queue if called before SDK initialization completes.
GDPR Compliance
For users in regions requiring GDPR compliance, enable non-personalized ads:
import { init, setNonPersonalizedAds } from '@empower-nokta/react-native-mobile-ads';// Option 1: During initializationinit({appAdIdentifier: 'your_app_identifier',nonPersonalizedAds: true,});// Option 2: At runtime based on user consentsetNonPersonalizedAds(!userHasGivenConsent);
Runtime Configuration
You can change SDK settings at runtime using these functions:
import {setDebugMode,setLogLevel,setNonPersonalizedAds,setAdsDisabled,} from '@empower-nokta/react-native-mobile-ads';// Enable/disable debug modesetDebugMode(false);// Change log levelsetLogLevel('error');// Toggle non-personalized adssetNonPersonalizedAds(true);// Disable all ads (e.g., for premium users)setAdsDisabled(true);
Checking SDK Status
import { isSdkInitialized } from '@empower-nokta/react-native-mobile-ads';const isReady = await isSdkInitialized();if (isReady) {// Safe to load ads}
Shutdown
Use shutdown() when you no longer want to show ads:
import { init, shutdown } from '@empower-nokta/react-native-mobile-ads';// Stop all ads and release resourcesshutdown();// Reinitialize when you want to show ads againinit({ appAdIdentifier: 'your_app_identifier' });