iOS Full Screen Interstitial

Full Screen Interstitial

Interstitial ads provide full-screen experiences, commonly incorporating rich media to offer a higher level of interactivity. Interstitials are typically shown during natural transitions in your app, e.g. after completing a game level, or while waiting for a new view to load.

Integration steps

1. Import Libraries
@import ChocolatePlatform_SDK_Core;
2. Declare a¬†ChocolateInterstitialAd instance with property in your app’s UIViewController
@property(nonatomic,strong) ChocolateInterstitialAd *interstitial;
3. Declare ChocolateAdDelegate Instance
@interface InterstitialExampleViewController () < ChocolateAdDelegate>
4. Initialize ChocolateInterstitialAd

self.interstitial = [[ChocolateInterstitialAd alloc] initWithDelegate:self];

Note: you must initialize the Chocolate SDK with the API key provided by us, as described above. No ads will be displayed otherwise.

 

5. Load the ad

[self.interstitial load];
6. Implement event listeners for ChocolateAdDelegate.


# pragma mark - ChocolateAdDelegate Methods
-(void)onChocolateAdLoaded:(ChocolateAd *)ad {
   [self.interstitial showFrom:self];
}

-(void)onChocolateAdLoadFailed:(ChocolateAd *)ad because:(ChocolateAdNoAdReason)reason {
    self.interstitial = nil;
}
-(void)onChocolateAdShown:(ChocolateAd *)ad {}
-(void)onChocolateAdClosed:(ChocolateAd *)ad {
    self.interstitial = nil;
}
-(void)onChocolateAdClicked:(ChocolateAd *)ad {}

Note: if you are using multiple instances of Chocolate ads (whether of the same ad unit or different ad units), make sure the callback is acting appropriately for the ad involved. The simplest way is to check the ad’s identity:


-(void)onChocolateAdLoaded:(ChocolateAd *)ad {
    if(ad == self.interstitial) {
        //the declared interstitial ad is loaded
    } else {
        //another ad, process appropriately for that ad
    }
}
7. Show interstitial ad by calling showFrom: method.

[self.interstitial showFrom:self];
Example Sample Code

@import ChocolatePlatform_SDK_Core;

@interface InterstitialExampleViewController ()<ChocolateAdDelegate>
@property(nonatomic,strong) ChocolateInterstitialAd * interstitial;
@end

@implementation InterstitialExampleViewController
- (void)viewDidLoad {
   [super viewDidLoad];
   
   self.interstitial = [[ChocolateInterstitialAd alloc] initWithDelegate:self];
   [self.interstitial load];
}

# pragma mark - ChocolateAdDelegate Methods
-(void)onChocolateAdLoaded:(ChocolateAd *)ad {
   [self.interstitial showFrom:self];
}

-(void)onChocolateAdLoadFailed:(ChocolateAd *)ad because:(ChocolateAdNoAdReason)reason {
    self.interstitial = nil;
}
-(void)onChocolateAdShown:(ChocolateAd *)ad {}
-(void)onChocolateAdClosed:(ChocolateAd *)ad {
    self.interstitial = nil;
}
-(void)onChocolateAdClicked:(ChocolateAd *)ad {}
@end

You can choose the view controller from which to present the ad at the time of launch:


[interstitialAd showFrom:[[[UIApplication sharedApplication] keyWindow] rootViewController]];

How to turn on ads on your ad unit

Please send us your sample app with the integrated code. We will help you validate the SDK setup and turn on the demand.