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

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.linkOpenerDelegate = self;
  self.adsRenderingSettings.linkOpenerPresentingController = 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 IMALinkOpenerDelegate 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<IMALinkOpenerDelegate>
And in the implementation:
- (void)linkOpenerWillOpenExternalBrowser:(NSObject *)linkOpener {
  NSLog(@"External browser will open.");
}

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

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

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

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