Banner Integration for iOS

Mobile banner ads are typically displayed at the top or bottom of the screen, and stick to the screen for the duration of the user’s session. Banner ads are a very popular ad unit for mobile apps because they are easy to implement and are a great tool for promoting advertiser awareness.
ironSource offers 4 types of system-initiated banner ads that can be either static or animated.

Before you start Make sure you have correctly integrated the ironSource SDK into your application. Integration is outlined here.

Note! As for version 6.15.0 Safe Area solution will not be provided by ironSource SDK. If you are using ironSource banner solution with SDK < 6.15.0, and wish to upgrade your SDK version, make sure you follow these steps.

Step 1. Implement the Delegate

The ironSource SDK fires several delegate methods to inform you of Banner activity. The SDK will notify your delegate methods of all possible events listed below:

#pragma mark - ISBannerDelegate
/** Called after a banner ad has been successfully loaded
 */
- (void)bannerDidLoad:(ISBannerView *)bannerView {}
/**
 Called after a banner has attempted to load an ad but failed.
 
 @param error The reason for the error
 */
- (void)bannerDidFailToLoadWithError:(NSError *)error {}
/**
 Called after a banner has been clicked.
 */
- (void)didClickBanner {}
/**
 Called when a banner is about to present a full screen content.
 */
- (void)bannerWillPresentScreen {}
/**
 Called after a full screen content has been dismissed.
 */
- (void)bannerDidDismissScreen {}
/**
 Called when a user would be taken out of the application context.
 */
- (void)bannerWillLeaveApplication {}
/MARK: Banner Delegates
    
   /**
     Called after a banner ad has been successfully loaded
     */
    func bannerDidLoad(_ bannerView: ISBannerView!)
    
   /**
     Called after a banner has attempted to load an ad but failed.
     @param error The reason for the error
     */
    func bannerDidFailToLoadWithError(_ error: Error!)
   /**
     Called after a banner has been clicked.
     */
    func didClickBanner()
    
   /**
     Called when a banner is about to present a full screen content.
     */
    func bannerWillPresentScreen()
   /**
     Called after a full screen content has been dismissed.
     */
    func bannerDidDismissScreen()
    
   /**
     Called when a user would be taken out of the application context.
     */
    func bannerWillLeaveApplication()
Note:  Do not assume the delegate methods are invoked on the main thread context. 

Step 2. Load Banner Ad

To load a banner ad, call the following method:

  • Initiate the Banner view by calling this method (in this example it’s the BANNER banner size):
    [IronSource loadBannerWithViewController:self size:ISBannerSize_BANNER];

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

    ISBannerSize Description Dimensions in points (WxH)
    ISBannerSize_BANNER Standard Banner 320 x 50
    ISBannerSize_LARGE Large Banner 320 x 90
    ISBannerSize_RECTANGLE Medium Rectangular Banner 300 x 250
    ISBannerSize_SMART
    Smart Banner
    (Adjusted for both iPhone and iPad)
    If (iPhone ≤ 720) 320 x 50
    If (iPad > 720) 728 x 90
  • Another option is initiating the banner with Custom size, using this signature (WxH in points):
    [IronSource loadBannerWithViewController:self size:[[ISBannerSize alloc] initWithWidth:320 andHeight:50];

Create and load a banner ad:

Here’s an example that initiates and loads a banner in the viewDidLoad method:

#import "ViewController.h"
#import <IronSource/IronSource.h>
 
@interface ViewController () <ISBannerDelegate>
 
@property (nonatomic, strong) ISBannerView      *bannerView;
 
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
 
    [IronSource setBannerDelegate:self];
    [IronSource initWithAppKey:@"YOUR_APP_KEY" adUnits:@[IS_BANNER]];
   
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:@"UIDeviceOrientationDidChangeNotification"
                                               object:nil];
   
    [IronSource loadBannerWithViewController:self size:ISBannerSize_BANNER];
}
 
#pragma mark - Orientation delegate
- (void)orientationChanged:(NSNotification *)notification {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (self.bannerView) {
            CGFloat y = self.view.frame.size.height - (self.bannerView.frame.size.height / 2);
            if (@available(ios 11.0, *)) {
                y -= self.view.safeAreaInsets.bottom;
            }
            self.bannerView.center = CGPointMake(self.view.frame.size.width / 2, y);
        }
    });
}
 
#pragma mark - Banner Delegate Functions
- (void)bannerDidLoad:(ISBannerView *)bannerView {
    dispatch_async(dispatch_get_main_queue(), ^{
        self.bannerView = bannerView;
       
        CGFloat y = self.view.frame.size.height - (self.bannerView.frame.size.height / 2);
        if (@available(ios 11.0, *)) {
            y -= self.view.safeAreaInsets.bottom;
        }
        self.bannerView.center = CGPointMake(self.view.frame.size.width / 2, y);
       
        [self.view addSubview:self.bannerView];
    });
}
 
- (void)bannerDidFailToLoadWithError:(NSError *)error {
}
 
- (void)didClickBanner {
}
 
- (void)bannerWillPresentScreen {
}
 
- (void)bannerDidDismissScreen {
}
 
- (void)bannerWillLeaveApplication {
}
 
@end

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.

Implement Safe Area:

Here’s an example that initiates and loads a banner in the bannerDidLoad method:

- (void)bannerDidLoad:(ISBannerView *)bannerView {
   NSLog(@"%s",__PRETTY_FUNCTION__);
   dispatch_async(dispatch_get_main_queue(), ^{
       self.bannerView = bannerView;
       if (@available(iOS 11.0, *)) {
           [self.bannerView setCenter:CGPointMake(self.view.center.x,self.view.frame.size.height - (self.bannerView.frame.size.height/2.0) - self.view.safeAreaInsets.bottom)]; // safeAreaInsets is available from iOS 11.0
       } else {
           [self.bannerView setCenter:CGPointMake(self.view.center.x,self.view.frame.size.height - (self.bannerView.frame.size.height/2.0))];
       }
       [self.view addSubview:self.bannerView];
   });
}

 

Step 4. Additional Load Settings

We support placementspacing and capping for Banners on the ironSource dashboard. Learn how to set up placements, capping and pacing for Banners to optimize your app’s user experience here.

If you’ve set up placements for your Banner, call the following method to serve a Banner ad in a specific placement:

[IronSource loadBannerWithViewController:self size:ISBannerSize_BANNER placement:placement];
IronSource.loadBanner(with: YOUR_VIEW_CONTROLLER, size: YOUR_BANNER_SIZE, placement: YOUR_PLACEMENT_NAME)
Note: SDK willnot show more than one banner at a time.

Step 5. Destroy the Banner Ad

To destroy a banner, call the following method:

[IronSource destroyBanner: bannerView];
IronSource.destroyBanner(YOUR_IRONSOURCE_BANNER)

A destroyed banner can no longer be loaded. If you want to serve it again, you must initiate it again.

Step 6.  Integrate a Banner Provider


Next, integrate the ad network adapters to serve Banners through ironSource Mediation.
You can find the supported networks below, and bannerSize behaviour for each network below:  

BANNER LARGE RECTANGLE SMART
ironSource Banner Large Banner / Leaderboard
AdColony Banner Banner Medium Rectangle Banner / Leaderboard
AdMob Banner Large* Medium Rectangle Banner / Leaderboard
Amazon Banner
Banner Banner Leaderboard **
AppLovin Banner Banner Medium Rectangle Banner / Leaderboard
Chartboost Banner Banner Medium Rectangle Banner / Leaderboard
Facebook Banner Large Medium Rectangle Banner / Leaderboard
Fyber Banner Banner Medium Rectangle Banner / Leaderboard
InMobi Banner Banner Medium Rectangle Banner / Leaderboard
Snap Banner Medium Rectangle
UnityAds Banner Banner Leaderboard
Vungle Banner Banner Medium Rectangle Banner / Leaderboard
  • Banner:  320 X 50
  • Large Banner:  320×90   
  • Medium / Rectangle: 300×250 
  • LeaderBoard: 728X90  

* AdMob define Large as 320X100
** Amazon define Leaderboard as 728X50

Done!
You are now all set up to serve Banners in your application. Verify your integration with our Integration Helper.


What’s Next? 

Follow our integration guides to integrate additional ad units:

Interested in integrating more mediation adapters? Check out our supported Mediation Networks.