Banner Ads

Set up a Banner Ad

  1. From the left navigation panel, select Inventory Inventory Settings.
  2. Search for the app or website you would like to create a placement for and click + Add a placement.
  3. Click Select Ad Unit and select Banner.
  4. Click Add a placement to start setting up your banner settings. After you create the banner placement, you can see the placement ID.

Add the Banner Ad to your App

Creating a Banner Ad

The IMBanner is simply a UIView subclass displaying HTML ads. The InMobi SDK provides two mechanisms to implement a banner ad:

Programmatic Instantiation

1. Import the headers and declare a Banner instance in your ViewController.h file or import the frameworks and declare a Banner instance in your ViewController.swift file. Your ViewController header file should look like this:

Objective C

#import <UIKit/UIKit.h> 
@import InMobiSDK; 
@interface ViewController : UIViewController <IMBannerDelegate> 
@property (nonatomic, strong) IMBanner *banner; 


import UIKit
import InMobiSDK
class ViewController: UIViewController, IMBannerDelegate {
    var banner: IMBanner?

2. Instantiate the banner object. Your ViewController.m file should look like this:

Objective C

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.banner = [[IMBanner alloc] initWithFrame: CGRectMake(0, 0, 320, 50) placementId:<placementId>]; 
    self.banner.delegate = self; 
    [self.view addSubview:self.banner]; 
    [self.banner load]; 


override func viewDidLoad() {
        banner = IMBanner.init(frame: CGRect(x: 0, y: 0, width: 320, height:
            50), placementId: <Insert your placement ID here>)
        banner?.delegate = self
        // Use this API to enable or disable auto refresh
        // Use this API to set a custom refresh interval on the banner
        banner?.refreshInterval = <refresh interval>

By default, IMBanner refreshes after every 60 seconds. You can also set a custom refresh interval or turn off AutoRefresh to manually load ads. For both manual load and Auto Refresh, the minimum time interval between two successive ad loads should be 20 seconds.


// to turn off auto refresh set the below value to NO.
[self.banner shouldAutoRefresh:NO];

//to set custom refresh interval
[self.banner setRefreshInterval:40];


// to turn off auto refresh set the below value to NO.   banner?.shouldAutoRefresh(false).   //to set custom refresh interval banner?.refreshInterval = 40

3. If at any time you want to release the banner:

Objective C

[self.banner removeFromSuperview];
self.banner.delegate = nil;
self.banner = nil;


// perform the deinitialization
banner?.delegate = nil
banner = nil

4. For ad status callbacks, implement the delegate methods of IMBannerDelegate. We support the following callbacks:

Objective C

// Notifies that the ad is received with Meta info. 
- (void)banner:(IMBanner*)banner didReceiveWithMetaInfo:(IMAdMetaInfo*)info {
    NSLog(@"Banner Ad is received")
- (void)bannerDidFinishLoading:(IMBanner *)banner {
- (void)banner:(IMBanner *)banner didFailToLoadWithError:(IMRequestStatus *)error {
    NSLog(@"banner failed to load ad");
    NSLog(@"Error : %@", error.description);
- (void)bannerWillPresentScreen:(IMBanner *)banner {
- (void)bannerDidPresentScreen:(IMBanner *)banner {
- (void)bannerWillDismissScreen:(IMBanner *)banner {
- (void)bannerDidDismissScreen:(IMBanner *)banner {
- (void)userWillLeaveApplicationFromBanner:(IMBanner *)banner {
-(void)banner:(IMBanner *)banner didInteractWithParams:(NSDictionary *)params{
-(void)banner:(IMBanner*)banner rewardActionCompletedWithRewards:(NSDictionary*)rewards{


// Notifies that the ad is received with Meta info.
public func banner(_ banner: IMBanner!, didReceiveWith info: IMAdMetaInfo!) {
    NSLog("Banner Ad is received")
public func bannerDidFinishLoading(_ banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func banner(_ banner: IMBanner!, didFailToLoadWithError error: 
IMRequestStatus!) {
    NSLog("[ViewController %@]", #function)
    NSLog("Banner ad failed to load with error %@", error)
public func banner(_ banner: IMBanner!, didInteractWithParams params: 
[AnyHashable : Any]!) {
    NSLog("[ViewController %@]", #function)
public func userWillLeaveApplication(from banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func bannerWillPresentScreen(_ banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func bannerDidPresentScreen(_ banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func bannerWillDismissScreen(_ banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func bannerDidDismissScreen(_ banner: IMBanner!) {
    NSLog("[ViewController %@]", #function)
public func banner(_ banner: IMBanner!, rewardActionCompletedWithRewards rewards: 
[AnyHashable : Any]!){
    NSLog("[ViewController %@]", #function)

You can use the following transitions while refreshing your banner object:

Objective C

  • UIViewAnimationTransitionNone
  • UIViewAnimationTransitionFlipFromLeft
  • UIViewAnimationTransitionFlipFromRight
  • UIViewAnimationTransitionCurlUp
  • UIViewAnimationTransitionCurlDown


  • none
  • flipFromLeft
  • flipFromRight
  • curlUp
  • curlDown

Objective C

self.banner.transitionAnimation = UIViewAnimationTransitionCurlUp;


banner?.transitionAnimation = .curlUp

Using Interface Builder

  1. Place the UIView in your ViewController’s view at the position where the ad should be displayed.
  2. Set the banner frame.
  3. Set the Class Identity of the UIView to IMBanner.
  4. In your ViewController header file, declare an IBOutlet instance of IMBanner.
  5. Set this as your outlet in your UIView(Banner) in the ViewController Scene in the Storyboard.
  6. In viewDidLoad(), enter the banner.placementId = <insert placement id>.

On This Page

Last Updated on: 25 Aug, 2021