Banner Integration

Banner ads usually appears at the top or bottom of your app’s screen. Adding one to your app takes just a few lines of code.

Prerequisites:

Before integrating banner ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project.

Basic integration

Adding a banner to your application takes only a few, easy steps:

  1. In your view controller's header file:
    • Import the INAdView.h header file and declare an INAdView *adView property.
    • Declare that your view controller implements the INAdViewDelegate protocol.
  2. In your view controller's implementation file, instantiate an INAdView, passing in your ad unit ID. This is typically done in -viewDidLoad.
  3. Register your view controller as the adView's delegate.
  4. Implement the -viewControllerForPresentingModalView INAdViewDelegate method. The adView will use the view controller returned by this method to present modals when tapped. Typically your controller can simply return self.
  5. Finally, load an ad by sending adView the -loadAd message.

Sample Code

- (void)viewDidLoad {
    [super viewDidLoad];

    self.adView = [[INAdView alloc] initWithAdUnitId:@"YOUR_ADUNIT_ID"];
    self.adView.delegate = self;    
    [self.bannerContainer addSubview:self.adView];

    [self.adView loadAd];
}

Implement non optional INAdViewDelegate protocol

#pragma mark - <INAdViewDelegate>
- (UIViewController *)viewControllerForPresentingModalView {
    return self;
}

Delegates

Detecting When a Banner Ad is Loaded

- (void)adViewDidLoadAd:(INAdView *)view;
- (void)adViewDidFailToLoadAd:(INAdView *)view;

Detecting When a User Interacts With the Ad View */

- (void)willPresentModalViewForAd:(INAdView *)view;
- (void)didDismissModalViewForAd:(INAdView *)view;
- (void)willLeaveApplicationFromAd:(INAdView *)view;

A complete ViewController is available in sample app.