ios-guidelines | Rewarded Video Ads

Rewarded Video ads are short (15 sec), non-skippable HD videos, which a user opts-in to watch in exchange for rewards like virtual goods or in-game gifts. Preferred by acquisition and brand marketers, these are perfect for integrating in shop fronts, start of gameplay or end of gameplay and help increase the retention of the non paying users. With the reward action dependent only on completed video views, rewarded video ads provide high quality engaged users to advertisers and high eCPMs to publishers.

Follow these simple steps and start monetizing with Rewarded Video ads:

Setting up a Rewarded Video Ad

After adding your app, select REWARDED VIDEO to create a placement for ad type Rewarded video.

Once you select the placement type as rewarded video, you will be presented with the following.

You can fill in the key value pair for reward details. SDK will provide this dictionary as a JSON string through a delegate method called interstitial:rewardActionCompletedWithRewards: when the video play has ended. You can also choose to handle these rewards completely at your end.

Creating a Rewarded Video Ad

Rewarded Video ads use IMInterstitial Class. The IMInterstitial is simply a UIViewController subclass displaying full screen ads that respond to user touch.

Follow these steps to create the rewarded video ad unit programmatically:

  1. Import the headers and declare an interstitial instance in your ViewController.h 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
    		
  2. 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];
    }
    		

    Important: Create only one object per placement ID and reuse it for subsequent ad loads.

  3. 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");
    }
    /* Indicates that a reward action is completed */
    - (void)interstitial:(IMInterstitial *)interstitial rewardActionCompletedWithRewards:(NSDictionary *)rewards {
        NSLog(@"rewardActionCompletedWithRewards");
    }
    /* 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");
    }
    		
  4. 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. Keep listening to the interstitial states to call show only when the ad is fully loaded.
  • 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.
  • Implement the interstitial:rewardActionCompletedWithRewards: method of IMInterstitialDelegate to detect video completion. If you have specified rewards on the InMobi portal, you can access the JSON dictionary here.

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

  1. 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 devices
    Set Test Mode to Selective ON.

    In the device section:

    1. In the Device ID box, type the device ID.
    2. In the Device Name box, set any name.
    3. 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.

    Getting 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 the AppDelegate.m file, as shown below:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {    
    	//Initialize InMobi SDK with your account ID
    [IMSdk initWithAccountID:@"Insert InMobi account ID here"];
    //Set log level to Debug
    [IMSdk setLogLevel:kIMSDKLogLevelDebug]; 
    	// Do your stuff.
    	return YES;
    }
    		

    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.

  2. You will also get feedback on the diagnostics tab on the ad unit and ad request and this can be particularly helpful during integration.

  3. You should also see these key InMobi SDK logs in console when a rewarded video 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>

  4. Now you would also see the InMobi test ads on your application.
  5. 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. 6.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 <Device Id>

Rewarded 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> with error:<Status code / message>
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.