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.
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:
+ (void)setLevelPlayBannerDelegate:(nullable id<LevelPlayBannerDelegate>)delegate;
#pragma mark - LevelPlayBannerDelegate
/**
Called after each banner ad has been successfully loaded, either a manual load or banner refresh
@param adInfo The info of the ad.
*/
- (void)didLoad:(ISBannerView *)bannerView withAdInfo:(ISAdInfo *)adInfo{
}
/**
Called after a banner has attempted to load an ad but failed.
This delegate will be sent both for manual load and refreshed banner failures.
@param error The reason for the error
*/
- (void)didFailToLoadWithError:(NSError *)error{
}
/**
Called after a banner has been clicked.
@param adInfo The info of the ad.
*/
- (void)didClickWithAdInfo:(ISAdInfo *)adInfo{
}
/**
Called when a user was taken out of the application context.
@param adInfo The info of the ad.
*/
- (void)didLeaveApplicationWithAdInfo:(ISAdInfo *)adInfo{
}
/**
Called when a banner presented a full screen content.
@param adInfo The info of the ad.
*/
- (void)didPresentScreenWithAdInfo:(ISAdInfo *)adInfo{
}
/**
Called after a full screen content has been dismissed.
@param adInfo The info of the ad.
*/
- (void)didDismissScreenWithAdInfo:(ISAdInfo *)adInfo{
}
You can view the full listeners implementation here.
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 (MREC) 300 x 250 ISBannerSize_SMART
Smart Banner
(Automatically renders ads to adjust size and orientation for iPhone & 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];
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)didLoad:(ISBannerView *)bannerView withAdInfo:(ISAdInfo *)adInfo{ 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 placements, pacing and capping for Banners on the Unity LevelPlay 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 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 Unity LevelPlay.
You can find the supported networks below, and bannerSize behaviour for each network below:
BANNER | LARGE | RECTANGLE | SMART | |
ironSource | Banner | Large | Medium Rectangle | 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 |
Meta Audience Network |
Banner | Large | Medium Rectangle | Banner / Leaderboard |
Digital Turbine | Banner | Banner | Medium Rectangle | Banner / Leaderboard |
HyprMX | Banner | – | Medium Rectangle | Banner / Leaderboard |
InMobi | Banner | Banner | Medium Rectangle | Banner / Leaderboard |
UnityAds | Banner | Banner | Medium Rectangle | Leaderboard |
Vungle | Banner | Banner | Medium Rectangle | Banner / Leaderboard |
Banner Size Reference
- Banner: 320 X 50
- Large Banner: 320×90
- Medium Rectangle (MREC): 300×250
- LeaderBoard: 728X90
* AdMob define Large as 320X100
** Amazon define Leaderboard as 728X50
Step 6. Adaptive banners
The adaptive banner feature will allow you to receive the optimal banner size, based on an ad-width and the screen size.
While using this feature, networks that support adaptive banners (Currently AdMob and Ad Manager only) will return ads with best-fit-height based on your banner size.
All other networks will continue to deliver banners according to the specified ad size.
- When you define your banner size add the “adaptive” flag
ISBannerSize.adaptive=YES;
- Receive the ad size as part of the load-success delegate didLoad, both for load and refreshed banner ads, allowing you to adjust the banner view in your app.
Done! What’s Next? Follow our integration guides to integrate additional ad units: Interested in integrating more mediation adapters? Check out our supported Mediation Networks.
You are now all set up to serve Banners in your application. Verify your integration with our Integration Helper.