ios-guidelines | Full-screen Video Ads
- Objective C
- Swift
Full-screen video ads are short (15-30 sec), skippable videos, which help in monetization with high eCPMs. Preferred by brands and game developers, these are perfect for happy moments such as level wins and wait times in Player vs Player (PVP). Video ads leverage the power of sight, sound, and motion to create immersive experiences for the user thereby enhancing the in-app ad experience.
|
|
To create a video ad, you need to use an interstitial ad placement. On creating an interstitial ad placement you will find controls on the InMobi portal to either run a mix of static and video ads OR 100% video ads only.
You also have access to advanced video controls on whether you want to run skippable video ads and only when the user is on Wifi.
Follow these simple steps and start monetizing with Video ads:
Setting up a Full-screen Video Ad
After adding your app, select INTERSTITIAL to create a placement for ad type Interstitial.
Once you create the Interstitial placement, you will have the placement id.
Creating a Full-screen Video Ad
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
file. YourViewController
header file should look like this:#import <UIKit/UIKit.h> @import InMobiSDK; @interface ViewController : UIViewController <IMInterstitialDelegate> @property (nonatomic, strong) IMInterstitial *interstitial; @end
-
Instantiate the interstitial object. Your
viewDidLoad
method inViewController.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]; }
Important: Create only one object per placement ID and reuse it for subsequent ad loads.
-
For ad status callbacks, implement the delegate property of
IMInterstitial
. The following callbacks are supported:/*Indicates that the interstitial is ready to be shown */ - (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial { NSLog(@"interstitialDidFinishLoading"); } /* Indicates that the interstitial has failed to receive an ad. */ - (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:(IMRequestStatus *)error { NSLog(@"Interstitial failed to load ad"); NSLog(@"Error : %@",error.description); } /* Indicates that the interstitial has failed to present itself. */ - (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:(IMRequestStatus *)error { NSLog(@"Interstitial didFailToPresentWithError"); NSLog(@"Error : %@",error.description); } /* Indicates that the interstitial is going to present itself. */ - (void)interstitialWillPresent:(IMInterstitial *)interstitial { NSLog(@"interstitialWillPresent"); } /* Indicates that the interstitial has presented itself */ - (void)interstitialDidPresent:(IMInterstitial *)interstitial { NSLog(@"interstitialDidPresent"); } /* Indicates that the interstitial is going to dismiss itself. */ - (void)interstitialWillDismiss:(IMInterstitial *)interstitial { NSLog(@"interstitialWillDismiss"); } /* Indicates that the interstitial has dismissed itself. */ - (void)interstitialDidDismiss:(IMInterstitial *)interstitial { NSLog(@"interstitialDidDismiss"); } /* Indicates that the user will leave the app. */ - (void)userWillLeaveApplicationFromInterstitial:(IMInterstitial *)interstitial { NSLog(@"userWillLeaveApplicationFromInterstitial"); } /* interstitial:didInteractWithParams: Indicates that the interstitial was interacted with. */ - (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:(NSDictionary *)params { NSLog(@"InterstitialDidInteractWithParams"); } /* Not used for direct integration. Notifies the delegate that the ad server has returned an ad but assets are not yet available. */ - (void)interstitialDidReceiveAd:(IMInterstitial *)interstitial { NSLog(@"interstitialDidReceiveAd"); }
-
To show the Interstitial ad, use the following code:
[self.interstitial showFromViewController:self]; //[self.interstitial showFromViewController:self withAnimation:kIMInterstitialAnimationTypeCoverVertical];
Here are the possible animation types:
kIMInterstitialAnimationTypeCoverVertical
kIMInterstitialAnimationTypeFlipHorizontal
kIMInterstitialAnimationTypeNone
Important: Make sure that interstitialDidFinishLoading
delegate is fired before making a call to showFromViewController
. Otherwise, the error callback interstitial:didFailToPresentScreenWithError:
will be fired. Every time an interstitial ad is shown and subsequently dismissed, you will need to invoke [self.interstitial load];
again. Without this, you won't be able to call showFromViewController
again.
Retrieving CreativeID
At times, there are rogue advertisers who escape all the ad quality checks and end up compromising the user experience on the app by showcasing either an irrelevant, distasteful or disrupting creative to the user. To combat such situations, you can retrieve the creativeID of the ad instance and report back to your InMobi point of contact with the encrypted creativeID.
mInterstitialAd.creativeId //mInterstitialAd
is an example instance.
Testing the Integration
-
Configure the Test Mode on InMobi portal.
Go to Tools - Diagnostics and switch Test Mode to either Global ON or Selective ON.
If you are integrating an ad unit for the first time Set Test Mode to Global ON. If you want to selectively turn on test traffic for a set of devices·
You already have a prior version of the SDK integrated for this particular ad unit and therefore you should restrict your testing to only few devicesSet Test Mode to Selective ON. In the device section:
- In the Device ID box, type the device ID.
- In the Device Name box, set any name.
- Click Add Device to add the test device.
If you already have a device configured, you can select the device and test mode would be enabled.
Note: You MUST turn off the test mode before going live or else your app will fail to monetize.
Now you are all set to get test ads.
How to get the Device ID
The device id is basically the IDFA or IFA (Identifier for Advertising). To get device ID, the easiest approach is to set the log level of the SDK to “debug”. To enable debug logs, add this to
didFinishLaunchingWithOptions
method within theAppDelegate.m
file, as shown below:if (NSClassFromString(@"ASIdentifierManager")) { deviceID = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; }
In the debug mode, the device ID will be logged on XCode developer console as:
“Publisher device ID is <device-id>”
You can enter this device id in the Device ID box.
- You will also get feedback on the diagnostics tab on the ad unit and ad request and this can be particularly helpful during integration.
-
You should also see these key InMobi SDK logs in console when a interstitial ad is successfully loaded:
[InMobi] InMobi SDK initialized with account id: <your account id here>
[InMobi] Fetching interstitial ad for placement id: <your placement id here>
[InMobi] Publisher device id is <device id here>
[InMobi] Interstitial ad successfully fetched for placement id: <your placement id here>
- Now you would also see the InMobi test ads on your application.
-
If the SDK is not initialised correctly before creating an ad, you would typically see these logs :
** ERROR ** [InMobi] ___ Please initialize the SDK before creating a <ad format>
ad. ** ERROR ** [InMobi] ___ Account id cannot be null or empty. Please provide a valid Account id.
[InMobi] Invalid account id passed to init. Please provide a valid account id.
The complete set of key logs are documented in the following tables.
SDK Initialization
Scenario | Log Level | Logs |
Publisher passed null or empty account id | Error | Account id cannot be null or empty. Please provide a valid Account id. |
Publisher passed a valid account id | Debug |
InMobi SDK initialized with account id: <account id>
|
Publisher passed an invalid account Id | Error | Invalid account id passed to init. Please provide a valid account id. |
Newer version of SDK is available | Debug | A newer version (ver. 9.0.0) of the InMobi SDK is available! You are currently on an older version (ver. 5.3.1). Download the latest InMobi SDK from http://www.inmobi.com/products/sdk/#downloads |
Ads Common
Scenario | Log Level | Logs |
Ad requested when no network available | Error | Network not reachable currently. Please try again. |
Ad requested when ad state is loading or available | Error |
An ad load is already in progress. Please wait for the load to complete before requesting for another ad (Placement id :<placement id>
|
Ad requested when ad is viewed by user | Error |
An ad is currently being viewed by the user. Please wait for the user to close the ad before requesting for another ad (Placement id : <placement id>
|
Publisher device Id | Debug |
Publisher device id is
|
Video Ads
Scenario | Log Level | Logs |
Publisher created a interstitial without initializing the SDK | Error | Please initialize the SDK before creating a interstitial ad |
Publisher created a interstitial with an invalid placement id | Error | Please provide a valid placement id to create a interstitial ad |
Publisher called load on an interstitial | Debug | Fetching an interstitial ad for placement id: <placement id> |
Successfully fetched ad | Debug |
Interstitial ad successfully fetched for placement id: <placement id>
|
Failed to fetch the ad | Error |
Failed to fetch Interstitial ad for placement id:<Placement id>
|
Started loading the interstitial in a webview | Debug |
Started loading Interstitial ad markup in the webview for placement id: <Placement id>
|
Interstitial successfully loaded in the webview | Debug |
Successfully loaded Interstitial ad markup in the webview for placement id: <placement id>
|
Failed to load interstitial in the webview | Error |
Failed to load the Interstitial markup in the webview for placement id: <placement id>
|
Interstitial Ad displayed | Debug |
Successfully displayed Interstitial for placement id:<placement id>
|
Interstitial Ad dismissed | Debug |
Interstitial ad dismissed for placement id:<placement id>
|
Ad show before ready Show ad before it's ready | Error | Ad Load is not complete. Please wait for the Ad to be in a ready state before calling show |
Full screen ad cannot be displayed without a view controller. Please pass a view controller to present the full screen ad. | Error | Full screen ad cannot be displayed without a view controller. Please pass a view controller to present the full screen ad. |