Mobile Ads Settings
Before starting, first you must configure the SDK via
EMASettings.shared or via
EMASettings sharedInstance if you are using Objective-C.
EMASettings.shared.rootViewController = self.window!.rootViewControllerEMASettings.shared.appIdentifier = "YOUR_APP_IDENTIFIER"EMASettings.shared.isAdsPersonalized = false
If you are not using a window property, you should pass your app's
rootViewController reference, which is the initial view controller of your main storyboard.
If you have the user's consent on displaying personalized ads, you may set
true or to
YES if you are using Objective-C.
Some properties of
EMASettings are for testing and debugging purposes.
The optional parameters are:
isAdsDisabled: The default value is
false. Set this value to
trueif you don't want your users to see ads. E.g. you may not want your premium users to see ads.
isUserLoggedInWithFB: Default value is
false. Used for user targeting. Set this value to
trueif the current user is logged in via Facebook.
logLevel: The default value is
LogLevel.none. Set this value to
LogLevel.allto print out all debug messages. Other values are:
testingType: The default value is
AdTestingType.none. This may be used to test the DFP Banner Ads, DFP Interstitial Ads, AdMob Banner Ads, AdMob Interstitial Ads or IMA Preroll Ads. Please don't forget to remove this setting before submitting your app to the App Store!
testDevices: If you'd like to test the ads via your device's testing id then add the value to this property. Please don't forget to remove this setting before submitting your app to the App Store!
Note: If a user is using the app with the VoiceOver enabled, then all ads will be disabled. To learn more about VoiceOver, please visit Apple's Accessibility page.
Initializing the SDK
After configuring the SDK with at least the required parameters, you must call
sendAppView method of
EMAManager.shared, which initializes the SDK and sends a notification of type
Notification.Name.AdLib.AdsReadyForDisplayNotification once the initialization is complete. This only needs to be done once, ideally at the application launch. Please also note that
EMAManager.shared.isAdsReadyForDisplay is set to
true once the initialization process is completed.
You can also add
EMAManager.shared.appViewDelegates property to listen
sendAppView events with
appViewFailed. Note that
sendAppView may get called multiple times in one session.
NotificationCenter.default.addObserver(self, selector: #selector(adsReadyForDisplayNotification), name: Notification.Name.AdLib.AdsReadyForDisplayNotification, object: nil)EMAManager.shared.sendAppView()