We support both static and video interstitial ads. Follow the instructions below to set up interstitial ads.
From there you can select your Ad Experience template. If you haven’t created an Ad Experience template yet, you can select the default Interstitial ad template created by InMobi which can contain both static and video creatives. You can always create your own template from Inventory Ad Experience Template. For more information, see Ad Experience Settings. After you create the Interstitial placement, you can see the placement ID.
The IMInterstitial
is simply a UIViewController
subclass displaying full-screen ads that respond to user touch.
Follow these steps to create the interstitial ad unit programmatically:
Import the headers and declare an interstitial instance in your ViewController.h /
ViewController.swift
file. Your ViewController
header file should look like this:
#import <UIKit/UIKit.h>
@import InMobiSDK;
@interface ViewController : UIViewController <IMInterstitialDelegate>
@property (nonatomic, strong) IMInterstitial *interstitial;
@end
import UIKit
import InMobiSDK
class ViewController: UIViewController, IMInterstitialDelegate {
var interstitial: IMInterstitial?
}
Instantiate the interstitial object. Your viewDidLoad
method in ViewController.m
file should look like this:
-(void)viewDidLoad {
[super viewDidLoad];
self.interstitial = [[IMInterstitial alloc] initWithPlacementId:<Insert your placement ID here>];
self. interstitial.delegate = self;
[self.interstitial load];
}
override func viewDidLoad() {
super.viewDidLoad()
interstitial = IMInterstitial.init(placementId: <Insert your placement ID here>)
interstitial?.delegate = self
interstitial?.load()
}
For ad status callbacks, implement the delegate methods of IMInterstitialDelegate
. Here are the supported callbacks:
// Notifies that the ad is received with Meta info.
- (void)interstitial:(IMInterstitial *)interstitial didReceiveWithMetaInfo:(IMAdsMetaInfo*)metaInfo {
NSLog(@"interstitial didReceiveAdWithMetaInfo");
}
- (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidFinishLoading");
}
- (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:
(IMRequestStatus *)error {
NSLog(@"Interstitial failed to load ad");
NSLog(@"Error : %@",error.description);
}
- (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:
(IMRequestStatus *)error {
NSLog(@"Interstitial didFailToPresentWithError");
NSLog(@"Error : %@",error.description);
}
- (void)interstitialWillPresent:(IMInterstitial *)interstitial {
NSLog(@"interstitialWillPresent");
}
- (void)interstitialDidPresent:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidPresent");
}
- (void)interstitialWillDismiss:(IMInterstitial *)interstitial {
NSLog(@"interstitialWillDismiss");
}
- (void)interstitialDidDismiss:(IMInterstitial *)interstitial {
NSLog(@"interstitialDidDismiss");
}
- (void)userWillLeaveApplicationFromInterstitial:(IMInterstitial *)interstitial {
NSLog(@"userWillLeaveApplicationFromInterstitial");
}
- (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:
(NSDictionary *)params {
NSLog(@"InterstitialDidInteractWithParams");
}
public func interstitialDidReceiveAd(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitialDidFinishLoading(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitial(_ interstitial: IMInterstitial, didFailToLoadWithError error: IMRequestStatus) {
print("[ViewController %@] \(#function)")
print("Interstitial ad failed to load with error \(error)" )
}
public func interstitialWillPresent(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitialDidPresent(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitial(_ interstitial: IMInterstitial, didFailToPresentWithError error: IMRequestStatus) {
print("[ViewController %@] \(#function)")
print("Interstitial ad failed to present with error \(error)" )
}
public func interstitialWillDismiss(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitialDidDismiss(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
public func interstitial(_ interstitial: IMInterstitial, didInteractWithParams params: [String : Any]?) {
print("[ViewController %@] \(#function)")
}
public func interstitial(_ interstitial: IMInterstitial, rewardActionCompletedWithRewards rewards: [String : Any]) {
print("[ViewController %@] \(#function)")
}
public func userWillLeaveApplicationFromInterstitial(_ interstitial: IMInterstitial) {
print("[ViewController %@] \(#function)")
}
To show the Interstitial Ad, use the following code:
[self.interstitial showFrom:self];
[self.interstitial showFrom:self with:IMInterstitialAnimationTypeAsNone];
interstitial?.show(from: self)
//interstitial?.show(from: self, with:.coverVertical)
Here are the possible animation types:
IMInterstitialAnimationTypeCoverVertical
IMInterstitialAnimationTypeFlipHorizontal
IMInterstitialAnimationTypeAsNone
Important:
interstitialDidFinishLoading
callback is received before making a call to showFromViewController
. Otherwise, the error callback interstitial:didFailToPresentScreenWithError:
will be given.[self.interstitial load];
again. Without this, you won't be able to call showFromViewController
again.Here are the possible animation types:
coverVertical
flipHorizontal
None
Important:
interstitialDidFinishLoading
callback is received before making a call to show(from viewController: UIViewController!)
. Otherwise, the error callback interstitial(_ interstitial: IMInterstitial!, didFailToLoadWithError error: IMRequestStatus!)
will be given.interstitial?.load()
again. Without this, you won't be able to call show(from viewController: UIViewController!)
again.By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.