4. Interstitial Ad‎ > ‎2) iOS‎ > ‎

Old APIs

These APIs are now deprecated. Please apply newly introduced APIs.

[Incentive Interstitial Ad]

To display incentive interstitial ads in your app, simply write down two lines of code as follows.

Incentive Ad Sample

    [[TnkSession sharedInstance] prepareInterstitialAd:TNK_PPI delegate:nil];

    [[TnkSession sharedInstance] showInterstitialAd];

[Non-Incentive Intestitial Ad]

To display non-incentive interstitial ads in your app, simply write down two lines of code as follows.

Non-Incentive Ad Sample

    [[TnkSession sharedInstance] prepareInterstitialAd:TNK_CPC delegate:nil];

    [[TnkSession sharedInstance] showInterstitialAd];


To catch events when an interstitial ad is loaded or users close interstitial ads, use TnkAdViewDelegate protocol.

TnkAdViewDelegate protocol

// Constants for Interstitial TnkAdViewDelegate

#define AD_CLOSE_SIMPLE     0   // User closed view by clicking close button.

#define AD_CLOSE_CLICK      1   // User clicked an ad and the view is closed.

#define AD_FAIL_NO_AD       -1  // no ad available

#define AD_FAIL_NO_IMAGE    -2  // ad image not available

#define AD_FAIL_TIMEOUT     -3  // ad arrived after 5 secs.

#define AD_FAIL_CANCEL      -4  // skip by ad frequency settings

#define AD_FAIL_SYSTEM      -9

#define TNK_PPI             @"__tnk_ppi__"

#define TNK_CPC             @"__tnk_cpc__"

@protocol TnkAdViewDelegate <NSObject>


// Called when AdListView is closed

- (void)adListViewClosed;

// Called when interstitial view is closed. Reason type is passed in the parameter.

- (void)adViewDidClose:(int)type;

// Called when failed to display ad.

// Error code is passed in the parameter

- (void)adViewDidFail:(int)errCode;

// Called when interstitial ad is displayed

- (void)adViewDidShow;

// Called when an interstitial ad is loaded from server.

// If show() method is called before ad is loaded, 

// then adViewDidShow is called instead of adViewDidLoad 

// when an interstitial ad is loaded.

- (void)adViewDidLoad;


Methods of TnkAdViewDelegate are listed as follows.
  • adViewDidClose:(int) type : Called when interstitial ad is closed.
    • AD_CLOSE_SIMPLE (0) : User closed ad view by clicking close button.
    • AD_CLOSE_CLICK (1) : User clicked and ad view is closed.
  • adViewDidFail:(int) errCode : Called when interstitial ad cannot be loaded.
    • AD_FAIL_NO_AD (-1) : No ad from server.
    • AD_FAIL_NO_IMAGE (-2) : No ad image found.
    • AD_FAIL_TIIMEOUT (-3) : Ad not loaded in 5 secs after showInterstitialAd: invoked. Ad is not displayed.
    • AD_FAIL_CANCEL (-4) : Ad loading is canceled by the frequency of ad configured at Tnk site.
    • AD_FAIL_SYSTEM (-9) : Server or network failure.
  • adViewDidLoad : Called when an interstitial ad is successfully loaded from server. If showInterstitialAd: method invoked before ad is loaded, then on arriving ad from server, adViewDidLoad is not called. Instead. adViewDidShow is called and ad is displayed immediately.
  • adViewDidShow : Called when ad is displayed on screen.
prepareInterstitialAd: and showInterstitialAd: method can have TnkAdViewDelegate object as last parameter. 
Following sample code shows how developers can control displaying interstitial ads using TnkAdViewDelegate.

TnkAdViewDelegate Sample

#import "tnksdk.h"

@interface ViewController : UIViewController <TnkAdViewDelegate> {

    // ...


@implementation ViewController

- (IBAction) interstitialPressed:(id)sender {

    [[TnkSession sharedInstance] prepareInterstitialAd:TNK_PPI delegate:self];


#pragma mark - TnkAdViewDelegate

- (void) adListViewClosed {

    NSLog(@"Ad list closed");


- (void) adViewDidClose:(int)type {

    NSLog(@"### didClose %d", type);


- (void) adViewDidFail:(int)errCode {

    NSLog(@"### didFail %d", errCode);


- (void) adViewDidShow {

    NSLog(@"### didShow");


- (void) adViewDidLoad {

    NSLog(@"### didLoad");

    if (isOkToShow) {

        [[TnkSession sharedInstance] showInterstitialAd];



[Interstitial Ad APIs]

API specs for prepareInterstitialAd: and showInterstitialAd:

- TnkSession - prepareInterstitialAd:

  - (void) prepareInterstitialAd:(NSString *)logicName delegate:(id<TnkAdViewDelegate>)delegate

   It loads a single interstitial Ad from server and cache it in memory.

 Name Description
 logicName Enter TNK_PPI for incentive ads and TNK_CPC for non-incentive ads.
Or enter any other string for Display Logic See 5) Display Logic for details.
 delegate TnkAdViewDelegate object or nil

- TnkSession - showInterstitialAd:

  - (void) showInterstitialAd
  - (void) showInterstitialAd:(id<TnkAdViewDelegate>)delegate

   It displays an interstitial ad which is loaded by prepareInterstitialAd: call before. TnkAdViewDelegate.adViewDidShow is invoked when the ads is successfully displayed on screen and TnkAdViewDelegate.adViewDidFail: is invoked when the ads is not loaded in 5 seconds.

 Name Description
 delegateTnkAdViewDelegate objet or nil