Overview
Starting with Vungle SDK v.6.4.3, Vungle supports MREC video ads. MREC is an abbreviation for "medium rectangle" ads. Unlike interstitial ads, MREC ads do not require a fullscreen view. Similar to banner ads, MREC video ads are rectangular ads occupying a location anywhere within the app's layout, typically displayed on the top or bottom of the screen, so that the user can continue to interact with the app while the ad is playing. The container size to render an MREC ad is the industry standard: 300x250.
Step 1. Complete Basic Integration
To integrate MREC ads in your iOS app, begin by following the instructions in the basic integration article. This MREC Ads article contains supplementary information and assumes you have completed basic integration.
Step 2. Receive Delegate Callbacks
This is a very important step for every format. Follow the instructions in the Receive Delegate Callbacks section of the Advanced Settings article.
Step 3. Load, Display, and Close an MREC Ad
Load an MREC Ad
The placement type for MREC must have the type MREC in the Liftoff Monetize dashboard.
Check Ad Availability for a Placement
Once the SDK finishes caching an ad for a placement, the following callback method is called:
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID error:(nullable NSError *)error;
Sample code:
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(NSString *)placementID error:(nullable NSError *)error { NSLog(@"vungleAdPlayabilityUpdate called"); }
func vungleAdPlayabilityUpdate(_ isAdPlayable: Bool, placementID: String?) {
print("vungleAdPlayabilityUpdate called")
}
Note: For the cache-optimized placements, this callback method is called only when an ad becomes available. The SDK will keep requesting an ad for these placements. For all other placements, this callback method is called in case of “Load Failed” (isAdPlayable
returns ‘NO’ in this case).
You can also check the ad availability for a placement with the following property:
- (BOOL)isAdCachedForPlacementID:(nonnull NSString *)placementID;
Display an MREC Ad
You must first create a container for the MREC ads. This container is a UIView
with the size of 300 × 250. You can place this UIView
anywhere on the screen. You must then call the addAdViewToView
function to associate the container with the MREC ad.
Function overview:
/**
* Pass in an UIView which acts as a container for the ad experience. This view container may be placed in random positions.
* @param publisherView container view in which an ad will be displayed
* @param options A reference to an instance of NSDictionary with customized ad playback options
* @param placementID The placement defined on the Liftoff Monetize dashboard
* @param error An optional double reference to an NSError. In case this method returns `NO` it will be non-nil
* @return YES/NO in case of success/error while presenting an AdUnit
*/
- (BOOL)addAdViewToView:(UIView *)publisherView withOptions:(nullable NSDictionary *)options placementID:(nullable NSString *)placementID error:( NSError *__autoreleasing _Nullable *_Nullable)error;
Sample code:
NSError *error;
VungleSDK *sdk = [VungleSDK sharedSDK];
if (![sdk addAdViewToView:_mrecViewArea withOptions:options placementID:@"Your_placement_ID_Here" error:&error]) {
if (error) {
NSLog(@"Error encountered while playing an ad: %@", error);
}
}
Close an MREC Ad
To close an MREC ad, call the finishedDisplayingAd
function. Depending on the implementation, you may need to include some cleanup (such as removing the MREC container UIView
from its parent view, etc).
Function overview:
- (void)finishDisplayingAd:(NSString *)placementId;
//Deprecated as of 6.7.0
- (void)finishedDisplayingAd;
Sample code:
//Ad is no longer on screen VungleSDK *sdk = [VungleSDK sharedSDK]; [sdk finishedDisplayingAd:@"MREC_PLACEMENTID_HERE"];
Step 4. Customize MREC Ads (Optional)
Mute Option
The Vungle SDK instance offers the option to play ads with the sound disabled. You can set the muted property to YES before issuing a playAd()
.
Sample code:
VungleSDK *sdk = [VungleSDK sharedSDK]; sdk.muted = YES;
var sdk:VungleSDK = VungleSDK.shared()
sdk.muted = true
Note: This option only applies to the standard ad type for Vungle SDK version 6.3.1 and lower. The muted option for Dynamic Template ads is available to configure on the dashboard. Starting with Vungle SDK v6.3.2, Vungle will respect the SDK-side mute setting for all ads.
Pass the Mediation Ordinal
If you receive ordinal data reports from Vungle, use the VunglePlayAdOptionKeyOrdinal
field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here.
Step 5. Test an MREC Ad
You can test an MREC Ad in one of two ways: by setting your app status to Test Mode so that Vungle can deliver test ads to your app, or by adding a test device to your app so that Vungle can deliver test ads specifically to the test device. Follow the instructions in Test Your Integration: Test Mode and Test Devices.