Before You Start

Before integrating ads unit in your app, you must:

  • In the OpenMediation UI, create an application and create an ad placement. You can follow guides here.
  • Follow our steps to iOS SDK Integration by integrating the OpenMediation SDK into your project.
  • If you use mediation, go to Add Mediation Networks and make sure you have added the ad networks' SDKs and the corresponding adapters you wish to work with in your app.


Banners are rectangular, system-initiated ads that served in a designated area around your live app content.

Step 1. Initialize Banner Ad

The OpenMediation SDK fires several events to inform you of Banner Ad activity. To display Banner Ads, one needs to create a brand new OMBanner object, set up its Delegate and load the ads.

Create OMBanner Object

The following snippet demonstrates how to use the OMBanner class to create Banner objects and implement the OMBannerDelegate interface to receive Banner Ad events. The SDK will notify the Delegate of all possible events listed below:

@property (nonatomic, strong) OMBanner *banner;
- (OMBanner*)banner{
         _banner = [[OMBanner alloc] initWithBannerType:OMBannerTypeDefault placementID:@"YOUR_PLACEMENT_ID"];
         [_banner addLayoutAttribute:OMBannerLayoutAttributeHorizontally constant:0];
         [_banner addLayoutAttribute:OMBannerLayoutAttributeVertically constant:0];
         _banner.delegate = self;
         [self.view addSubview:_banner];
   return _banner;
private lazy var banner: OMBanner = {
let banner = OMBanner(bannerType: OMBannerType.default, placementID: "YOUR_PLACEMENT_ID")
banner.add(.horizontally, constant: 0)
banner.add(.vertically, constant: 0)
banner.delegate = self
return banner

See table below for details about our supported standard banner sizes:

OMBannerType Size
OMBannerTypeDefault 320 x 50
OMBannerTypeMediumRectangle 300 x 250
OMBannerTypeLeaderboard 728 x 90
OMBannerTypeSmart If (iPhone) 320 x 50
If (iPad) 728 x 90


Banner Delegate (OMBannerDelegate)

Implement the following callback functions in your code to process ad logic when receiving the status of your ad. For example invoke loadAndShow function to serve Ad to your users when the Banner Ad is ready.  

The methods declared by the OMBannerDelegate protocol allow the adopting delegate to respond to messages from the OMBanner class and thus respond to operations such as whether the ad has been loaded, or the user has clicked the ad. 

/// Invoked when the banner ad is available.
- (void)omBannerDidLoad:(OMBanner *)banner {
     NSLog(@"BannerAd Did Load");

/// Invoked when the call to load a banner has failed.
/// Parameter error contains the reason for the failure.
- (void)omBanner:(OMBanner *)banner didFailWithError:(NSError *)error {
     NSLog(@"BannerAd Did Fail");

/// Invoked when the banner ad is showing.
- (void)omBannerWillExposure:(OMBanner *)banner {
     NSLog(@"BannerAd Will Exposure");

/// Invoked when the user clicks on the banner ad.
- (void)omBannerDidClick:(OMBanner *)banner {
     NSLog(@"BannerAd Did Click");
/// Invoked when the banner ad is available.
func omBannerDidLoad(_ banner: OMBanner) {
     print("BannerAd Did Load")

/// Invoked when the call to load a banner has failed.
/// Parameter error contains the reason for the failure.
func omBannerDidFail(toLoad banner: OMBanner, withError error: Error) {
     print("BannerAd Did Fail")

/// Invoked when the banner ad is showing.
func omBannerWillExposure(_ banner: OMBanner) {
     print("BannerAd Will Exposure")

/// Invoked when the user clicks on the banner ad.
func omBannerDidClick(_ banner: OMBanner) {
     print("BannerAd Did Click")


Step 2. Load and Show a Banner Ad

Invoke loadAndShow method to request and show the Banner Ad to your users.

[self.banner loadAndShow];

Notes: The loadAndShow method can be called multiple times at any time, but we do not recommend continuous requests within a short period of time. Making many requests in a short period of time makes no sense because the inventory's availability is unlikely to change much over this period. 

Please do not request Banner ads regularly in the application, OpenMediation SDK will automatically refresh Banner ads regularly.


Step 3. Safe Area Layout Implementation

Safe area refers to the layout guides introduced as part of iOS11, defining the allowed position views in iOS applications. It makes sure that your application will not cover any ancestor views, including navigation and tab bars.

if (@available(iOS 11.0, *)) {
    [_banner setCenter:CGPointMake(, self.view.frame.size.height - _banner.frame.size.height/2.0 - self.view.safeAreaInsets.bottom)];
 } else {
    [_banner setCenter:CGPointMake(, self.view.frame.size.height - _banner.frame.size.height/2.0)];
if #available(iOS 11.0, *) { = CGPoint.init(, y:self.view.frame.size.height - banner.frame.size.height/2.0 - self.view.safeAreaInsets.bottom)
 } else { = CGPoint.init(, y:self.view.frame.size.height - banner.frame.size.height/2.0)


Step 4. Integrate a Banner Provider

You can find the supported networks below, and bannerSize behaviour for each network below:  










Admob ✔️ ✔️ ✔️ ✔️
Facebook ✔️ ✔️ ✔️ ✔️
AdColony ✔️ ✔️ ✔️ ✔️
UnityAds ✔️   ✔️ ✔️
Vungle ✔️   ✔️ ✔️
AppLovin ✔️ ✔️ ✔️ ✔️
Pangle ✔️ ✔️ ✔️ ✔️
Mintegral ✔️ ✔️ ✔️ ✔️
TencentAds ✔️   ✔️ ✔️


Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.