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 level
nonPersonalizedAds: false, // GDPR: non-personalized ads only
variant: 'A', // Optional: A/B test variant
});

Configuration Options

OptionTypeDefaultDescription
appAdIdentifierstringRequired. Your app identifier from Empower.
debugModebooleanfalseEnables verbose logging and test ads. Disable in production.
logLevelstring'none'Controls the verbosity of SDK logs.
nonPersonalizedAdsbooleanfalseWhen true, serves only non-personalized ads (GDPR compliance).
variantstringundefinedOptional A/B test variant string.

Log Levels

LevelDescription
'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 needed
unsubscribe();
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 initialization
init({
appAdIdentifier: 'your_app_identifier',
nonPersonalizedAds: true,
});
// Option 2: At runtime based on user consent
setNonPersonalizedAds(!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 mode
setDebugMode(false);
// Change log level
setLogLevel('error');
// Toggle non-personalized ads
setNonPersonalizedAds(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 resources
shutdown();
// Reinitialize when you want to show ads again
init({ appAdIdentifier: 'your_app_identifier' });