Enable MoPub Mediation on iOS

Use this guide to add the Vungle iOS SDK into your app, using MoPub as your main advertising mediation layer.

Contents:

Before You Begin

Requirements

Integrate the Vungle iOS SDK and the MoPub Adapter Framework

  1. Download the Vungle SDK for iOS.
  2. Follow our integration instructions. 
  3. Follow MoPub's instructions to integrate the Vungle MoPub iOS Adapter Framework 6.8.1.0.

SKAdNetwork Support for iOS 14+

The Vungle iOS SDK v6.8.1 supports iOS 14 and SKAdNetwork 2.0. For more information on integrating the ATT Framework, a complete list of SKAdNetworkIDs, and a code snippet to integrate SKAdNetworkIDs to your Info.plist file, refer to our iOS integration instructions.

CCPA

As of July 1, 2020, the California Consumer Privacy Act (CCPA) is enforced, and publishers must update to iOS SDK v6.7.0 and MoPub adapter v6.7.0.0 to comply with CCPA.

To pass CCPA values, call the Vungle SDK API directly. This is the only feature that should be accessed directly through the Vungle SDK API. Other optional features should use VungleAdapterConfiguration class provided in the adapter.

Use updateCCPAStatus to set the user’s consent status; specify that the user has opted out by passing updateCCPAStatus:VungleCCPADenied. Use getCurrentCCPAStatus to get the current CCPA status for the particular user.

CCPA API

Update CCPAgetCurrentCCPAStatus
- (void)updateCCPAStatus:(VungleCCPAStatus)status;

Sample code

//To set the user's CCPA status to opt_out:
[[VungleSDK sharedSDK] updateCCPAStatus:VungleCCPADenied];
//To find out what the user's current CCPA status is:
[[VungleSDK sharedSDK] getCCPAStatus];
    

 

Banner Ad Size

Vungle supports following three banner ad sizes: Banner, MREC, Leaderboard. Use an ad container that is no smaller than the specified size, and use the corresponding size configuration when requesting banner ads.

Banner Formats Size MoPub Ad Size Configuration
Banner 320dp x 50dp size:MOPUB_BANNER_SIZE
Leaderboard 728dp x 90dp size:MOPUB_LEADERBOARD_SIZE
Medium rectangle 300dp x 250dp size:MOPUB_MEDIUM_RECT_SIZE
     
Flexible Banner 
(more details here)
SCREEN_WIDTH x 50 | 90 | 250 kMPPresetMaxAdSize50Height
kMPPresetMaxAdSize90Height
kMPPresetMaxAdSize250Height

Sample code: 

self.adView = [[MPSampleAppInstanceProvider sharedProvider] buildMPAdViewWithAdUnitID:self.info.ID size:MOPUB_MEDIUM_RECT_SIZE];

Optional Advanced Settings

Early SDK Initialization (Recommended)

MoPub iOS SDK v5.5.0 and higher allows you to initialize ad network SDKs early, as soon as the MoPub SDK completes initialization. We strongly recommend that you use this feature, because it will allow additional time for the Vungle SDK to pre-cache an ad and have it ready to play at the next display opportunity.

Sample code:

MPMoPubConfiguration * sdkConfig = [[MPMoPubConfiguration alloc]
initWithAdUnitIdForAppInitialization:@"MOPUB_AD_UNIT_WITH_VUNGLE_PLACEMENT"];

NSMutableDictionary *configDictionary = [NSMutableDictionary dictionaryWithDictionary:@{ @"appId" : @"YOUR_VUNGLE_APP_ID" }];
 
[sdkConfig setNetworkConfiguration:configDictionary forMediationAdapter:@"VungleAdapterConfiguration"];

[[MoPub sharedInstance] initializeSdkWithConfiguration:sdkConfig
   completion:^{
  NSLog(@"SDK initialization complete"); }];

Memory Settings

Starting with Vungle SDK v6.4.0, you can prevent the SDK from downloading, requesting ads, or even initializing if the storage of your iOS device falls below a predefined threshold.

These are the option keys available:

Keys

Type/Value

Description

vngMinSpaceForInit

Integer, value in MB, default value is 50

Sets the required minimum available free storage space to be able to initialize the SDK

vngMinSpaceForAdLoad

Integer, value in MB, default value is 50

Sets the required minimum available free storage space to be able to request an ad

 

Sample code:

NSMutableDictionary *configDictionary = [NSMutableDictionary dictionaryWithDictionary:@{ @"appId" : @"YOUR_VUNGLE_APP_ID" }];

[[NSUserDefaults standardUserDefaults] setValue:@(50) forKey:@"vngMinSpaceForInit"];
[[NSUserDefaults standardUserDefaults] setValue:@(50) forKey:@"vngMinSpaceForAdLoad"];
 
[sdkConfig setNetworkConfiguration:configDictionary forMediationAdapter:@"VungleAdapterConfiguration"];

Restrict Collection of IDFV

Starting with Vungle iOS SDK v6.4.3, you can now restrict the SDK from passing the IDFV when the Limit Ad Tracking option is enabled on a user's device. Import VungleRouter.h to access this API and use it in your AppDelegate before Vungle SDK is initialized.

Sample code:

#import "VungleRouter.h"

// Invoke setShouldCollectDeviceId before initialization of Vungle SDK
[VungleRouter.sharedRouter setShouldCollectDeviceId:NO];

Customize Rewarded Ads

You can use VungleInstanceMediationSettings to customize the rewarded ad experience.

These are the option keys available:

Keys

Type/Value

Description

orientations

0 Auto-rotate
1 Landscape
2 Portrait

Sets the orientation of the ad. We recommend allowing ads to auto-rotate, even if your app is in portrait. This way, the user has the option to watch full-size videos, resulting in a better user experience. You can achieve this by setting the orientation on a view controller level (rather than a project level).

startMuted YES or NO The Vungle SDK instance offers the option to play ads with the sound disabled. Please contact your account manager to enable it from Vungle dashboard as well.
userIdentifier String Sets your user ID. The value is passed to Vungle server, and then sent to your server through server-to-server callback system if a placement is set to "Rewarded."

 

Customize Interstitial Ads

Starting with MoPub adapter 6.4.5.1, you can use localExtras to pass customization options for interstitial ads.

These are the option keys available:

Keys

Type/Value

Description

orientations

NSNumber

0 Auto-rotate
1 Landscape
2 Portrait

Sets the orientation of the ad. We recommend allowing ads to auto-rotate, even if your app is in portrait. This way, the user has the option to watch full-size videos, resulting in a better user experience. You can achieve this by setting the orientation on a view controller level (rather than a project level).

muted

NSNumber

YES or NO

The Vungle SDK instance offers the option to play ads with the sound disabled. Please contact your account manager to enable it from Vungle dashboard as well.

Sample code:

NSNumber *orientations = [NSNumber numberWithInt:1];
NSString *ordinal = @"10";
NSNumber *muted = [NSNumber numberWithBool:YES];

NSDictionary *localExtras = @{@"muted" : muted ?: @"",
                              @"orientations" : orientations ?: @""};
    
self.interstitial.localExtras = localExtras;
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?