BETA - Integrating MoPub + Vungle SDK v.6.4.2(iOS)

Please direct integration issues or Beta related bugs to early.adoption@vungle.com. Beta SDKs will not be supported upon beta testing completion. We recommend you update to the latest SDK version, once Beta testing is completed.

Use this guide to add Vungle iOS SDK into your app, using MoPub as your main advertising mediation layer. MoPub iOS adapter 6.4.2.0 is compatible with Vungle iOS SDK 6.4.2.

Contents

Before You Begin

Step 1. Set Up Vungle as an SDK Network or as a Custom Native Network

Set Up Vungle as an SDK Network

  1. Log in to the MoPub dashboard and select Networks from the main navigation panel.
  2. Click New Network.



    and select Vungle.

  3. In the Network Settings section, if you Enable reporting access, enter your Reporting API Key from the Vungle Dashboard.

  4. In App & Ad Unit Setup, enter the Vungle Application ID and Placement Reference IDs.

Set Up Vungle as a Custom Native Network

To ensure that the MoPub servers recognize the integrated Vungle Adapters, set up Vungle as a Custom Native Network in the MoPub dashboard.

  1. Log into the MoPub dashboard, and navigate to Networks by the main navigation bar.
  2. Click New Network button on the top right.

    Screen_Shot_2018-05-08_at_2.53.52_PM.png
    and select Vungle from the list.
  3. After creating Vungle as a Network, click on the name from the list of Networks. In the Set Up Your Inventory section, for each ad unit that will use the Vungle SDK to present video ads, ensure that the MoPub SDK can find the network adapter used to interact with the Vungle SDK:

Screen_Shot_2018-05-09_at_3.49.13_PM.png

    • If you are using MoPub Rewarded Video​ for an Ad Unit, add VungleRewardedVideoCustomEvent under the Custom Event Class​ section.
    • If you are using Interstitial for an Ad Unit, add VungleInterstitialCustomEvent under the Custom Event Class.
    • If you are using MREC for an Ad Unit, add VungleBannerCustomEvent under the Custom Event Class.
    • Add your Vungle App ID, placement reference ID of the placement to be called from the ad unit, and all placement reference IDs in JSON format under the Custom Event Class Data.
    • Set the placement reference ID you want to link to the MoPub Ad Unit for pid.
    • Make sure to link a placement that is set to rewarded type at Vungle dashboard to the MoPub Ad Unit that is set to Rewarded Video​; and link a placement that is set to interstitial type at Vungle dashboard to the MoPub Ad Unit that is set to Fullscreen (320 x 480).
      {
      "appId":"59208865950e6d380100001f", 
      "pid":"DEFAULT07430"
      }

      Note: The Vungle SDK will cache an ad automatically for the placement selected to be Cache Optimized​ in the Vungle Dashboard. Please reach out to your Account Manager for more information.

Step 2. Add Vungle as a Third-Party Ad Network

To add the Vungle iOS SDK into your app using MoPub mediation:

  1. Add all the Vungle-related adapter files to /AdNetworkSupport/Vungle/ and make sure to include .m files in the project's Build Phases → Compile Sources.
    VungleAdapterConfiguration.h
    VungleAdapterConfiguration.m         
    VungleBannerCustomEvent.h
    VungleBannerCustomEvent.m    
    VungleInstanceMediationSettings.h
    VungleInstanceMediationSettings.m
    VungleInterstitialCustomEvent.h
    VungleInterstitialCustomEvent.m
    VungleRewardedVideoCustomEvent.h
    VungleRewardedVideoCustomEvent.m
    VungleRouter.h
    VungleRouter.m
  2. Copy the VungleSDK.framework folder into /AdNetworkSupport/Vungle/SDK/.

    • Make sure the project's Build Settings → Framework Search Path includes the framework. For example:
      $(PROJECT_DIR)/AdNetworkSupport/Vungle/SDK/VungleSDK.framework
    • Make sure the framework is included in the project's Build Phases → Link Binary With Libraries.
  3. Follow the instructions in the “Add Other Required Frameworks“ section of “Get Started with Vungle - iOS SDK“ to add the necessary frameworks.
  4. Follow the instructions in the “Add the “-ObjC” Linker Flag“ section of “Get Started with Vungle - iOS SDK“ to add the linker flag.
  5. Follow the instructions in the “Remove the iOS Status Bar“ section of “Get Started with Vungle - iOS SDK“ to remove the status bar.
  6. Call the MPInterstitialAdController’s showFromViewController method (or, for rewarded ads, call the MPRewardedVideo's presentRewardedVideoAdForAdUnitID method) when you want to present a Vungle video ad! (No need to call the Vungle iOS SDK methods directly. The MoPub SDK will do it.)

Optional Advanced Settings

Early SDK Initialization (Recommended)

MoPub iOS SDK 5.5.0 and above allows you to early initialize ad network SDK when MoPub SDK completes initialization. We strongly recommend you to use this feature as it will allow additional time for Vungle SDK to pre-cache an ad and have it ready to play at 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 from 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"];

Rewarded Ads Customization

You can use VungleInstanceMediationSettings to customize 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).

ordinal

Integer

If you receive ordinal data reports from Vungle, use this 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.

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."

 

Sample code:

VungleInstanceMediationSettings *settings = [[VungleInstanceMediationSettings alloc] init];

settings.userIdentifier = @"USER_ID"; // customerId will over-ride this
settings.startMuted = YES;
settings.orientations = @(0);
settings.ordinal = 10;

[MPRewardedVideo loadRewardedVideoAdWithAdUnitID:self.info.ID keywords:self.info.keywords userDataKeywords:nil location:nil mediationSettings:@[settings]];
Was this article helpful?
0 out of 0 found this helpful