Banner Integration for iOS Legacy pre v8.4.0
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.
Starting from ironSource SDK 7.8.0, you can use a container as part of your banner integration. Learn more.
The multiple ad units APIs are available here, supported for SDK 8.4.0+
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 |
AdMob | Banner | Large* | Medium Rectangle | Banner / Leaderboard |
APS | Banner |
– | Medium Rectangle | 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 height , based on a predefined ad-width.
While using this feature, networks that support adaptive banners (Currently AdMob and Ad Manager only) will return ads with best-fit-height based on the container width you defined. All other networks will continue to deliver banners according to the specified default ad size.
In this implementation (Supported from ironSource SDK 7.8.0+) the container defines the boundaries of the banner for all networks, whether they support adaptive banners or not. This ensures a consistent experience across each refresh during the same load session.
- Set the banner default size.
- Define adaptive banner parameters
- Width: the banner width you would like to display. Use either fix size, or the device’s width
- Height: use getMaximalAdaptiveHeightWithWidth API to get the recommended banner height for the width you defined in the previous step.
- Create a container, using the parameter sizes defined in step #1
- Set the adaptive flag to true.
- Load the banner
ISBannerSize *bannerSize = ISBannerSize_BANNER; // the banner size you choose will be the default value for non supporting banner adaptive networks
bannerSize.adaptive = YES;
CGFloat width = 320; // set width to your desired size
CGFloat adaptiveHeight = [ISBannerSize getMaximalAdaptiveHeightWithWidth:width];
ISContainerParams *containerParams = [[ISContainerParams alloc] initWithWidth:width height:adaptiveHeight];
[bannerSize setContainerParams:containerParams];
[IronSource loadBannerWithViewController:YOUR_VIEW_CONTROLLER size:bannerSize placement:YOUR_PLACEMENT_NAME];
let bannerSize = ISBannerSize.BANNER // The banner size you choose will be the default value for non-supporting banner adaptive networks
bannerSize.adaptive = true
let width: CGFloat = 320 // Set width to your desired size
let adaptiveHeight = ISBannerSize.getMaximalAdaptiveHeight(withWidth: width)
let containerParams = ISContainerParams(width: width, height: adaptiveHeight)
bannerSize.setContainerParams(containerParams)
IronSource.loadBanner(with: YOUR_VIEW_CONTROLLER, size: bannerSize, placement: YOUR_PLACEMENT_NAME)
The getMaximalAdaptiveHeightWithWidth method provides the maximum height for a given width in adaptive banner supported networks. If there are no networks that support adaptive banners, the returned value will be -1.
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.