Configuration

This guide explains how to initialize and configure the Empower Mobile Ads SDK in your Flutter application.

SDK Initialization

Initialize the SDK as early as possible in your application lifecycle — ideally in your root widget's initState or main() function.

Basic Initialization

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:empower_mobile_ads/empower_mobile_ads.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
final appId = Platform.isAndroid
? 'your_android_app_identifier'
: 'your_ios_app_identifier';
EmpowerAds.init(EmpowerAdsConfig(
appAdIdentifier: appId,
));
runApp(const MyApp());
}

Important: Replace the identifiers with the app identifiers provided by Empower.

Initialization with Options

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
EmpowerAds.init(EmpowerAdsConfig(
appAdIdentifier: 'your_app_identifier',
debugMode: false, // Enable debug logging (disable in production)
logLevel: 'default', // Log verbosity level
privacyMode: 'automatic', // GDPR privacy mode
consentFormDelay: 1.5, // iOS: delay before showing consent form
variant: 'A', // Optional: A/B test variant
));

Configuration Options

OptionTypeDefaultDescription
appAdIdentifierStringRequired. Your app identifier from Empower.
debugModeboolfalseEnables verbose logging and test ads. Disable in production.
logLevelString'default'Controls the verbosity of SDK logs.
privacyModeString'automatic'Privacy mode for ad personalization.
consentFormDelaydouble1.5iOS only: delay in seconds before showing the consent form.
variantString?nullOptional 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

Privacy Modes

ModeDescription
'automatic'SDK automatically handles privacy and consent
'nonPersonalized'Serves only non-personalized ads (GDPR compliance)
'manual'Full manual control over privacy settings

Listening for SDK Events (Optional)

The SDK provides Dart Streams for monitoring SDK and ad status changes:

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Listen for SDK events
EmpowerAds.onSdkReady.listen((event) {
print('Empower SDK is ready');
});
// Listen for banner status changes
EmpowerAds.onBannerStatusChanged.listen((event) {
final status = event['status'];
final zoneId = event['zoneId'];
print('Banner status: $status for zone: $zoneId');
});

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

Banner and app open ads automatically queue if called before SDK initialization completes. However, interstitial and rewarded ads should be loaded after the SDK is fully initialized to ensure reliable delivery.

A practical approach is to listen for the first banner status event (which signals that the SDK has finished parsing ad zones) before loading interstitials or rewarded ads:

import 'dart:async';
import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Initialize
EmpowerAds.init(EmpowerAdsConfig(
appAdIdentifier: 'your_app_identifier',
));
// App open ads queue automatically
EmpowerAds.loadAppOpenAd('app_open_zone_id');
// Load interstitial after SDK is ready (banner status is a reliable signal)
StreamSubscription? sub;
sub = EmpowerAds.onBannerStatusChanged.listen((_) {
EmpowerAds.loadInterstitialAd('interstitial_zone_id');
sub?.cancel(); // Only need to trigger once
});

GDPR Compliance

For users in regions requiring GDPR compliance:

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Option 1: During initialization
EmpowerAds.init(EmpowerAdsConfig(
appAdIdentifier: 'your_app_identifier',
privacyMode: 'nonPersonalized',
));
// Option 2: At runtime based on user consent
EmpowerAds.setNonPersonalizedAds(!userHasGivenConsent);

Runtime Configuration

You can change SDK settings at runtime using these methods:

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Enable/disable debug mode
EmpowerAds.setDebugMode(false);
// Change log level
EmpowerAds.setLogLevel('error');
// Toggle non-personalized ads
EmpowerAds.setNonPersonalizedAds(true);
// Disable all ads (e.g., for premium users)
EmpowerAds.setAdsDisabled(true);

Checking SDK Status

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
final isReady = await EmpowerAds.isSdkInitialized();
if (isReady) {
// Safe to load ads
}

Disabling Ads for Premium Users

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Disable all ads for premium users
void userPurchasedPremium() {
EmpowerAds.setAdsDisabled(true);
}
// Re-enable ads if subscription expires
void premiumSubscriptionExpired() {
EmpowerAds.setAdsDisabled(false);
}

Shutdown

Use shutdown() when you no longer want to show ads:

import 'package:empower_mobile_ads/empower_mobile_ads.dart';
// Stop all ads and release resources
EmpowerAds.shutdown();
// Reinitialize when you want to show ads again
EmpowerAds.init(EmpowerAdsConfig(
appAdIdentifier: 'your_app_identifier',
));