请使用本指南将 Vungle iOS SDK 添加到您的应用程序中,并使用 MoPub 作为您的主要广告中介层。
目录:
开始之前
要求
- MoPub iOS adapter 6.9.1.0兼容SDK 6.9.1并在MoPub iOS SDK 5.15.0和Xcode 12测试过。
- Vungle SDK v6.7.0+兼容MoPub SDK v.5.13+,但不兼容MoPub SDK v.5.12和以下版本。
- MoPub Dashboard不包含各个placement层级的数据。如有需要,请使用 Reporting API for Publishers,来查看placement层级数据。
- 请根据 MoPub’s iOS SDK integration instructions文档先进行集成配置。
- 请参阅我们有关 MoPub 与您的应用程序进行集成的说明文档。
- 插屏式广告:https://developers.mopub.com/docs/ios/interstitial/
- 奖励式视频: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/
- 请使用正确的Xcode和iOS SDK版本,详情请查看我们的集成文档。
- Vungle iOS SDK v.6.9.1 和 MoPub iOS adapter 6.9.1.0 支持 SKAdetwork, AppTrackingTransparency和Xcode12。
集成Vungle iOS SDK和MoPub Adapter
- 下载 Vungle SDK for iOS。
- 请查看文档integration instructions。
- 请根据文档 MoPub's instructions 来集成 Vungle MoPub iOS Adapter Framework 6.9.1.0。
支持仅iOS 14+ 支持SKAdNetwork
IOS Vungle SDK 6.8.0+ 在Xcode 12 上支持 iOS 14 和 SKAdNetwork 2.0 。 更多信息,请查看文档our iOS integration instructions。
CCPA
自2020年7月1日起,California Consumer Privacy Act (CCPA)开始实行。开发者需要更新SDK 6.7.0和MoPub adapter 6.7.0.0来符合CCPA。
为了传递CCPA值,您必须要直接调用Vungle SDK API。这也是唯一的一个功能,您需要直接调用Vungle SDK的API。 其他 optional features,其他optional features请使用 VungleAdapterConfiguration
。
根据 CCPA, consent 默认状态为opted in 。 Vungle.updateCCPAStatus
可设置为opted out。Vungle.getCCPAStatus
返回为null时,Vungle默认为 opted-in。
CCPA API
- (void)updateCCPAStatus:(VungleCCPAStatus)status;
- (VungleCCPAStatus)getCurrentCCPAStatus;
示例代码
//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支持3种banner尺寸:Banner, Medium rectangle, Leaderboard。请使用不小于这些广告尺寸大小的容器来展示这些广告。请使用size
高度来加载特定Banner广告。请注意,与其他配置为横幅的横幅尺寸相比,MREC(300dp x 250dp)必须具有从VungleDashboard上配置为MREC的单独的放置参考 reference ID。
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 (更多信息请查看 这里) |
SCREEN_WIDTH x 50 | 90 | 250 |
kMPPresetMaxAdSize50Height kMPPresetMaxAdSize90Height kMPPresetMaxAdSize250Height
|
示例代码:
self.adView = [[MPSampleAppInstanceProvider sharedProvider] buildMPAdViewWithAdUnitID:self.info.ID size:MOPUB_MEDIUM_RECT_SIZE];
高级设置
SDK提前初始化(强烈建议)
自MoPub5.5.0及以后版本,允许您可以在初始化MoPub后即刻初始化Ad Network SDK。我们强烈建议您使用该功能,这能让Vungle SDK有更多的时间来预缓存广告以增加展示的机会。
示例代码:
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
自SDK 6.4.0以后,您可以通过设置最小初始化和请求广告的存储空间来阻止SDK初始化和请求广告。
具体设置
Keys |
Type/Value |
说明 |
vngMinSpaceForInit |
Integer, value in MB, default value is 50 |
设置最小初始化的存储空间 |
vngMinSpaceForAdLoad |
Integer, value in MB, default value is 50 |
Sets the required minimum available free storage space to be able to request an ad |
示例代码
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"];
禁用IDFV
自从iOS SDK 6.4.3以后,当用户开启 Limit Ad Tracking时开发者可以禁止SDK获取IDFV 。请 import VungleRouter.h
在初始化之前调用该API。
示例代码
#import "VungleRouter.h"
// Invoke setShouldCollectDeviceId before initialization of Vungle SDK
[VungleRouter.sharedRouter setShouldCollectDeviceId:NO];
自定义Rewarded Ads
请使用 VungleInstanceMediationSettings 来自定义广告体验。
具体设置
Keys |
Type/Value |
说明 |
||||||
orientations |
|
设置广告展示方向。即使您的应用为横屏或竖屏应用,仍建议允许广告设置为auto-rotate以便广告自动旋转。因为这种模式,能够使全屏广告给更好的用户体验。 |
||||||
startMuted | YES or NO | Vungle SDK 提供静音播放功能。该功能也可以在Vungle Dashboard上控制,如有需要请联系您的客户经理。 | ||||||
userIdentifier | String | 设置user ID。在观看完奖励广告后,该值会传递给Vungle服务器,并通过S2S callback来传递给开发者。 |
自定义插屏广告
自MoPub adapter 6.4.5.1,您可以使用localExtras
来设置自定义选项给插屏广告
具体设置
Keys |
Type/Value |
说明 |
||||||
orientations |
NSNumber
|
设置广告展示方向。即使您的应用为横屏或竖屏应用,仍建议允许广告设置为auto-rotate以便广告自动旋转。因为这种模式,能够使全屏广告给更好的用户体验。 |
||||||
静音 |
NSNumber YES or NO |
Vungle SDK 提供静音播放功能。该功能也可以在Vungle Dashboard上控制,如有需要请联系您的客户经理。 |
示例代码
NSNumber *orientations = [NSNumber numberWithInt:1];
NSString *ordinal = @"10";
NSNumber *muted = [NSNumber numberWithBool:YES];
NSDictionary *localExtras = @{@"muted" : muted ?: @"",
@"orientations" : orientations ?: @""};
self.interstitial.localExtras = localExtras;