Early Access - Enable MoPub Mediation on Android v.6.7.0-early1

Use this guide to add Vungle Android SDK into your app, using MoPub as your main advertising mediation layer. MoPub Android adapter 6.7.0.0 is compatible with Vungle Android SDK 6.7.0.

Before You Begin

CCPA

As of July 1, 2020, California Consumer Privacy Act (CCPA) will be enforced and publishers must update to Android SDK 6.7.0 and MoPub adapter 6.7.0.0 to comply with CCPA.

To pass CCPA values, you must call the Vungle SDK API directly. This is the only feature that should be accessed directly through Vungle SDK API. Other optional features such as Android ID and memory settings should use VungleAdapterConfiguration class provided in the adapter.

Use Vungle.updateCCPAStatus to set the user’s consent status to specify that the user has opted out by passing Vungle.CCPAStatus.OPTED_OUT. And use Vungle.getCCPAStatus to get the current CCPA status for the particular user.

CCPA API
updateCCPAStatus getCCPAStatus
public static void updateCCPAStatus(@NonNull final Vungle.CCPAStatus status)
Sample Code
// To set the user's CCPA status to opted out:
Vungle.updateCCPAStatus(Vungle.CCPAStatus.OPTED_OUT);
// To find out what the user's current consent status is:
Vungle.CCPAStatus currentCCPAStatus = Vungle.getCCPAStatus();

Banner Ad

Vungle supports following 3 banner ad sizes: Banner, Medium rectangle, Leaderboard. Please use an ad container that is no smaller than the specified size and use corresponding MoPubView.MoPubAdSize height value when loading banner ads. Please note that MREC (300dp x 250dp) must have a separate placement reference ID configured as MREC from Vungle dashboard, compared to other banner sizes that is configured as banner.

MoPubAdSize Size
HEIGHT_50 320dp x 50dp
HEIGHT_90 728dp x 90dp
HEIGHT_250 300dp x 250dp
HEIGHT_280 300dp x 250dp
MATCH_VIEW Closest size that will fit in the view container

Sample code

@Override
public MoPubView.MoPubAdSize getAdSize() {
    return MoPubView.MoPubAdSize.HEIGHT_250;
}

Optional Advanced Settings

Early SDK Initialization (Recommended)

MoPub Android 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

SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Map<String, String> vungleSettings = new HashMap<>();

vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");

SdkConfiguration configBuilder = new SdkConfiguration.Builder("MOPUB_AD_UNIT_WITH_VUNGLE_PLACEMENT")
        .withMediatedNetworkConfiguration(VungleAdapterConfiguration.class.getName(), vungleSettings)
        .build();

MoPub.initializeSdk(this, configBuilder, initSdkListener());

Memory Settings

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

These are the option keys available:

Keys

Type/Value

Description

pre_key_min_space_for_init

String, value in bytes (default 51 MB)

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

pre_key_min_space_for_ad

String, value in bytes (default 50 MB)

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

 

Sample code

Map<String, String> vungleSettings = new HashMap<>();

vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");

vungleSettings.put("VNG_MIN_SPACE_INIT",
        mPreferences.getString("pref_key_min_space_for_init", String.valueOf(20 * 1024 * 1024)));
vungleSettings.put("VNG_MIN_SPACE_LOAD_AD",
        mPreferences.getString("pref_key_min_space_for_ad", String.valueOf(20 * 1024 * 1024)));

Restrict usage of device ID

For SDK version 6.4.10 onwards, publishers can now restrict from passing Android ID from the device to the SDK.

Map<String, String> vungleSettings = new HashMap<>();

vungleSettings.put("appId", "YOUR_VUNGLE_APP_ID");

vungleSettings.put("VNG_DEVICE_ID_OPT_OUT",
        String.valueOf(mPreferences.getBoolean("pref_key_key_android_id_opted_out", true)));

Interstitial Ads

You can pass custom ad configuration to customize your ad experience when load is issued for MoPubInterstitial. Please note that VungleMediationSettings has been deprecated as of v6.5.1.0 and replaced with VungleMediationConfiguration.

Attribute

Default Value

Description

withStartMuted

true

Play ad with sound muted or unmuted. Set to 'true' to play muted. Set to 'false' to play with sound.

withOrdinalViewCount

null

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.

withAutoRotate AdConfig.AUTO_ROTATE

Available Orientation:

  • AdConfig.AUTO_ROTATE
  • AdConfig.PORTRAIT
  • AdConfig.LANDSCAPE
  • AdConfig.MATCH_VIDEO

Example

VungleMediationConfiguration vungleMediationConfiguration = new VungleMediationConfiguration.Builder()
    .withAutoRotate(AdConfig.LANDSCAPE) 
    .withStartMuted(true) 
    .withOrdinalViewCount(10)
    .build();
mMoPubInterstitial.setLocalExtras(vungleMediationConfiguration.getExtrasMap());
mMoPubInterstitial.load();

Rewarded Ads

You can pass custom ad configuration to customize your ad experience when load is issued for MoPubRewardedVideos. Please note that VungleMediationSettings has been deprecated as of v6.5.1.0 and replaced with VungleMediationConfiguration.

Attribute

Default Value

Description

withUserId

null

Sets the unique user ID to pass to your application to verify that this user should be rewarded for watching an incentivized ad.

withCancelDialogBody

"Closing this video early will prevent you from earning your reward. Are you sure?"

Sets the body of the confirmation dialog when skipping an incentivized ad.

withCancelDialogCloseButton

“Close Video”

Sets the 'cancel button' text of the confirmation dialog when skipping an incentivized ad.

withCancelDialogKeepWatchingButton

“Keep Watching”

Sets the 'keep watching button' text of the confirmation dialog when skipping an incentivized ad.

withCancelDialogTitle

“Close Video?”

Sets the title of the confirmation dialog when skipping an incentivized ad.

withStartMuted

false

Sets the starting sound state for the ad. If 'false', the audio respects device volume and sound settings. If 'true', video begins muted but user may modify.

withOrdinalViewCount

null

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.

withAutoRotate

AdConfig.AUTO_ROTATE

Available Orientation:

  • AdConfig.AUTO_ROTATE
  • AdConfig.PORTRAIT
  • AdConfig.LANDSCAPE
  • AdConfig.MATCH_VIDEO

Example

VungleMediationConfiguration vungleMediationConfiguration = new VungleMediationConfiguration.Builder()
        .withUserId("VUNGLE_USER_ID")
        .withCancelDialogBody("CUSTOM_BODY")
        .withCancelDialogCloseButton("CUSTOM_CLOSE")
        .withCancelDialogKeepWatchingButton("CUSTOM_KEEPWATCHING")
        .withCancelDialogTitle("CUSTOM_TITLE")
        .withStartMuted(true)
        .withOrdinalViewCount(10)
        .withAutoRotate(AdConfig.AUTO_ROTATE)
        .build();

MoPubRewardedVideos.loadRewardedVideo(mAdUnitId, vungleMediationConfiguration);
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?