Banner Integration for iOS
Banners are rectangular, system-initiated ads that can be either static or animated, and are served in a designated area around your live app content.
Before You Start
- Make sure you have correctly integrated the ironSource SDK into your application. Integration is outlined here.
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 {
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];
});
}
/**
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()
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. Additional Load Settings
We support placements, pacing 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)
Step 4. 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 5. Integrate a Banner Provider
Next, integrate the ad network adapters to serve Banners through ironSource Mediation. We currently support ironSource, Admob, AppLovin, Facebook, Fyber and Inmobi Banners.
For better understanding of bannerSize’s behaviour per network, please follow table:
BANNER | LARGE | RECTANGLE | SMART | |
ironSource | Banner | Large | Banner / Leaderboard | |
AdMob | Banner | Large Banner | IAM Medium Rectangle | Banner / Leaderboard |
AppLovin | Banner | Banner | Medium Rectangle | Banner / Leader |
Standard Banner | Large Banner | Medium Rectangle | Banner / Leader | |
Fyber | Banner | Banner | Medium Rectangle | Banner / Leader |
InMobi | Banner_320_50 | Banner_320_50 | Banner_300_250 | Banner_320_50 / Banner_728_90 |
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.