Configuring clickthrough

This guide explains how to implement more control over clickthrough in your IMA SDK implementation. "Clickthrough" refers to the process of a user clicking on an ad and getting to the landing page for that ad. The examples in this guide demonstrates how to configure where that landing page opens and how to listen for events related to users visiting that page.

Prerequisites

An iOS application with the IMA SDK implemented.

Configuring clickthrough

Changing the web opener

The IMA SDK offers two options for opening ad landing pages—via an in-app browser, or via Safari. By default, the SDK opens pages using Safari. To update the SDK to use an in-app browser, you need to use IMAAdsRenderingSettings:
- (void)createAdsRenderingSettings {
  self.adsRenderingSettings = [[IMAAdsRenderingSettings alloc] init];
  self.adsRenderingSettings.webOpenerDelegate = self;
  self.adsRenderingSettings.webOpenerPresentingController = self;
}
Once you've configured the IMAAdsRenderingSettings instance, you can pass it to the IMAAdsManager initialization method:
[self.adsManager initializeWithAdsRenderingSettings:adsRenderingSettings];
The IMA SDK provides the IMAWebOpenerDelegate to communicate when the user is about to see or has just closed a clickthrough page. To use this delegate, add it to your delegate list in the header, and implement its methods. In the header:
@interface ViewController : UIViewController<IMAWebOpenerDelegate>
And in the implementation:
- (void)webOpenerWillOpenExternalBrowser:(NSObject *)webOpener {
  NSLog(@"External browser will open.");
}

- (void)webOpenerWillOpenInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser will open");
}

- (void)webOpenerDidOpenInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser did open");
}

- (void)webOpenerWillCloseInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser will close");
}

- (void)webOpenerDidCloseInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser did close");
}