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
- The MoPub iOS adapter 6.10.1.0 is compatible with Vungle iOS SDK 6.10.1 and has been tested with MoPub iOS SDK 5.17.0 using Xcode 12.5. Xcode 12.4 or lower will not be supported.
- Vungle MoPub iOS adapter v6.10.1.0 has been tested with MoPub SDK v.5.17.0. Vungle MoPub adapter 6.10.1.0 is not compatible with MoPub SDK v.5.16.2 and below.
- The MoPub Dashboard does not yet include Vungle placements; check your placement-level performance using our Reporting API for Publishers.
- MoPub must be set up in your app before starting this tutorial. For a step-by-step guide, refer to MoPub’s iOS SDK integration instructions.
- Refer to MoPub integration documentation about integrating MoPub with your app.
- Interstitial: https://developers.mopub.com/docs/ios/interstitial/
- Rewarded Video: https://developers.mopub.com/docs/ios/rewarded-video/
- Banner (320 x 50), Leaderboard (728 x 90), MREC (300 x 250): https://developers.mopub.com/publishers/ios/banner/
- Set up the application with the correct Xcode and iOS SDK version, as detailed in our iOS integration instructions.
- Vungle iOS SDK v.6.10.1 and MoPub iOS adapter 6.10.1.0 supports SKAdNetwork 2.2 and AppTrackingTransparency using Xcode 12.5
Integrate the Vungle iOS SDK and the MoPub Adapter Framework
- Download the Vungle SDK for iOS.
- Follow our integration instructions.
- Follow MoPub's instructions to integrate the Vungle MoPub iOS Adapter Framework 6.10.1.0.
Add the "-ObjC" Linker Flag
Click on your project in Project Navigator and go to Build Settings → Linking → Other Linker Flags. Add -ObjC to Other Linker Flags.
SKAdNetwork Support for iOS 14+
IOS Vungle SDK 6.8.0+ supports iOS 14 and SKAdNetwork 2.0 using Xcode 12. 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.
In accordance with CCPA, the consent status is opted in by default unless updateCCPAStatus has been explicitly called to set it as opted out. getCCPAStatus may return null if not set but will be treated as opted in.
CCPA API
- (void)updateCCPAStatus:(VungleCCPAStatus)status;
- (VungleCCPAStatus)getCurrentCCPAStatus;
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:
adView = [[MPSampleAppInstanceProvider sharedProvider] buildMPAdViewWithAdUnitID:self.info.ID size:MOPUB_MEDIUM_RECT_SIZE];
Optional Advanced Settings
Early SDK Initialization (Recommended for Waterfall but Required for In-App Bidding)
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 for waterfall, 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. Early SDK initialization is required for In-App Bidding.
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 |
|
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
|
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 ?: @""};
interstitial.localExtras = localExtras;