概览
Vungle Banner目前处于测试阶段。请直接与您的客户经理联系以获取访问权限,以确保成功启动。
自从SDK 6.4.3之后,Vungle支持MREC广告。MREC的全称是medium rectangle。不像插屏广告,MREC广告不需要全屏播放。类似Banner广告,MREC广告是一个长方形尺寸的广告,一般会展示在页面的顶部或底部。因此该种广告形式,不影响用户与应用交互。MREC广告的尺寸是行业规范为300x250。
步骤1. 完成基本集成
集成MREC,请先查看文档basic integration。
步骤2. Load,Display和Close广告
加载MREC广告
MREC的放置类型在Vungle仪表板中必须具有MREC类型。
检查展示位置的广告可用性
当 SDK 完成广告位置的广告缓存后,会调用以下回调方法:
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID error:(nullable NSError *)error;
示例代码:
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(NSString *)placementID error:(nullable NSError *)error { if([placementID isEqualToString:@"Your_placement_ID_Here"]) { self.playButtonPlacement1.enabled = isAdPlayable; } }
func vungleAdPlayabilityUpdate(_ isAdPlayable: Bool, placementID: String?) {
if (placementID == <Your_PlacementID>) {
self.playButtonPlacement1.enabled = isAdPlayable;
}
}
注意:对于缓存优化的展示位置,仅当广告可用时才调用此回调方法。 SDK将继续为这些展示位置请求广告。对于所有其他展示位置,在“加载失败”的情况下调用此回调方法(在这种情况下, isAdPlayable
返回“ NO”)。
您还可以通过以下属性来检查广告位置的广告可用性:
- (BOOL)isAdCachedForPlacementID:(nonnull NSString *)placementID;
显示MREC广告
您必须首先为MREC广告创建一个容器。此容器是一个UIView
为300×250大小,您可以把这个UIView
任意位置在屏幕上。然后,您必须调用addAdViewToView
函数将容器与MREC广告相关联。
函数概览:
/**
* Pass in an UIView which acts as a container for the ad experience. This view container may be placed in random positions.
* @param publisherView container view in which an ad will be displayed
* @param options A reference to an instance of NSDictionary with customized ad playback options
* @param placementID The placement defined on the Vungle dashboard
* @param error An optional double reference to an NSError. In case this method returns `NO` it will be non-nil
* @return YES/NO in case of success/error while presenting an AdUnit
*/
- (BOOL)addAdViewToView:(UIView *)publisherView withOptions:(nullable NSDictionary *)options placementID:(nullable NSString *)placementID error:( NSError *__autoreleasing _Nullable *_Nullable)error;
示例代码:
NSError *error;
NSDictionary *options = @{};
VungleSDK* sdk = [VungleSDK sharedSDK];
if (![sdk addAdViewToView:_mrecViewArea withOptions:options placementID:@"Your_placement_ID_Here" error:&error]) {
if (error)
{
NSLog(@"Error encountered while playing an ad: %@", error);
}
}
关闭MREC广告
要关闭MREC广告,调用finishedDisplayingAd
功能。此功能仅适用于MREC广告。请注意,此功能不接受展示位置;它只会关闭当前正在播放的所有MREC广告。根据实现的不同,您可能需要进行一些清理(例如从其父视图中删除MREC容器UIView
等)。
函数概览:
- (void)finishDisplayingAd:(NSString *)placementId;
//Deprecated as of 6.7.0
- (void)finishedDisplayingAd;
示例代码:
//Ad is no longer on screen VungleSDK* sdk = [VungleSDK sharedSDK]; [sdk finishedDisplayingAd:@"MREC_PLACEMENTID_HERE"];
步骤3. 配置MREC Ads (Optional)
静音选项
Vungle SDK提供静音设置。您可以在调用playAd()
方法时,传入静音设置。
示例代码:
VungleSDK* sdk = [VungleSDK sharedSDK]; self.sdk.muted = true;
var sdk:VungleSDK = VungleSDK.shared()
sdk.muted = true
注意:此选项仅适用于Vungle SDK 6.3.1及更低版本的标准广告类型。动态模板广告的静音选项可在仪表板上进行配置。从Vungle SDK v6.3.2开始,Vungle将尊重所有广告的SDK端静音设置。
传递Mediation Ordinal
如果您从Vungle收到顺序数据报告,请使用此字段传递中介顺序。这是一个整数,指示此广告在游戏会话中的显示顺序(例如,如果已经在该会话中显示了两个广告,然后将来自Vungle的该广告显示为第三,则传递“ 3”)。 在此处阅读有关序数数据的更多信息。