Integrate MREC Ads

Overview

Vungle MREC is currently in BETA phase. Please contact your account manager directly for access to ensure a successful launch.

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 Android or Amazon app, begin by following the instructions in the basic integration article. This article contains supplementary information and assumes you have completed basic integration.

Step 2. Load, Display, and Close an MREC Ad

Load an MREC Ad

The placement type for MREC has to have the type MREC in Vungle 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:

Objective-CSwift
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(NSString *)placementID error:(nullable NSError *)error {
    if([placementID isEqualToString:@"Your_placement_ID_Here"]) {
        self.playButtonPlacement1.enabled = isAdPlayable;
    }
}

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 Vungle 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;
NSDictionary *options = @{};
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. This function only works with MREC ads. Note that this function does not take in a placement; it will simply close any MREC ad currently playing. 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:

As of 6.7.0Deprecated
- (void)finishDisplayingAd:(NSString *)placementId;

Sample code:

//Ad is no longer on screen
VungleSDK* sdk = [VungleSDK sharedSDK];
[sdk finishedDisplayingAd:@"MREC_PLACEMENTID_HERE"];

Step 3. 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 'true' before issuing a playAd().

Sample code:

Objective-CSwift
VungleSDK* sdk = [VungleSDK sharedSDK];
self.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.

Powered by Creativity Driven by Performance Sign Up Here

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?