客户在注册成为腾讯广告联盟用户之后,联盟向客户提供本文档,作为其与联盟广告平台对接的指引文档。腾讯广告联盟拥有修改、调整、增补本文件的权利,并在法律允许范围内对本文档拥有最终解释权。
| 版本 | 日期 | 说明 |
|---|---|---|
| 4.8.1 | 2018-11-1 | 支持激励视频 |
| 4.8.0 | 2018-9-6 | 添加Swift Demo,修复 Bug |
| 4.7.9 | 2018-8-27 | 修复Bug |
| 4.7.8 | 2018-7-21 | 修复Bug |
| 4.7.7 | 2018-7-14 | 修复Bug |
| 4.7.6 | 2018-7-6 | 修复Bug |
| 4.7.5 | 2018-5-25 | 开屏广告新增曝光回调 |
| 4.7.4 | 2018-4-25 | 视频模板广告新增状态回调 |
| 4.7.3 | 2018-4-17 | 修复Bug |
| 4.7.2 | 2018-03-30 | 修复 Bug |
| 4.7.1 | 2017-03-07 | 优化开屏广告效果 |
| 4.7.0 | 2017-12-10 | 增加原生视频模板、适配 iPhone X、 支持 Auto Layout |
| 4.6.4 | 2017-10-25 | 优化广告位内存占用 |
| 4.6.3 | 2017-10-11 | 增加原生广告三小图接口 |
| 4.6.2 | 2017-08-29 | 增加原生广告接口 |
| 4.6.1 | 2017-07-28 | 修改返回的错误码 |
| 4.6.0 | 2017-07-13 | 增加原生模板广告形态支持,增加HTTPS支持 |
| 4.5.6 | 2017-03-01 | 修复Bug,增加错误码说明 |
| 4.5.5 | 2017-01-16 | 优化插屏视频落地页样式 |
| 4.5.4 | 2016-12-20 | 优化数据上报 |
| 4.5.2 | 2016-12-02 | 优化数据上报,开屏回调接口,打开广告的 体验优化。 |
| 4.5.1 | 2016-11-02 | 最低支持iOS7系统,优化数据上报 |
| 4.5.0 | 2016-10-08 | 开屏跳过按钮支持自定义,广告标识字样修改 |
| 4.4.9 | 2016-09-26 | 修复Bug. |
| 4.4.8 | 2016-09-12 | 优化数据上报,调整原生广告拉取上限 |
| 4.4.7 | 2016-08-25 | 增加广告标识 |
| 4.4.6 | 2016-08-18 | 优化广告体验 |
| 4.4.5 | 2016-08-01 | 优化开屏回调接口 |
| 4.4.3 | 2016-06-21 | 增加广告有效期的说明 |
| 4.4 | 2016-05-23 | 优化了广告点击体验 |
| 4.3.1 | 2016-04-18 | 移除ObjC链接依赖 |
| 4.3 | 2016-02-20 | 支持半屏开屏功能 |
| 4.2 | 2016-02-02 | SDK支持转化统计功能,优化点击行为。 |
| 4.1 | 2015-11-03 | SDK支持Bitcode,去除c++链接依赖, 不再对iOS4,5作支持。 |
| 4.0 | 2015-08-31 | 支持Banner、插屏、原生广告、开屏。 |
本文档旨在帮助您的iOS应用开发者在程序中快速植入腾讯广告联盟平台提供的广告,请按照下述指南进行操作。
APPID:媒体 ID,是您在腾讯广告联盟官网创建媒体时获得的ID,这个ID是我们在广告网络中识别您应用的唯一ID。
PlacementId:广告位 ID,是您在腾讯广告联盟官网为您的应用所创建的某种类型(Banner、开屏、插屏、原生)的广告位置的ID。
开发者需在联盟平台上自主注册,在平台审核通过后,开发者就成为了腾讯广告联盟的正式会员。
开发者在联盟平台上新建媒体及广告位,并记录下媒体ID、广告位ID,待接入SDK时使用。
确保您的开发及部署环境符合以下标准:
开发工具:Xcode 9及以上版本
部署目标:iOS 7.0及以上版本
确认使用的是官网最新的SDK版本。
使用联盟广告SDK,您的iOS应用可以借助腾讯完成广告创收。本章介绍了在您的iOS应用集成联盟广告iOS SDK的方法。
自动部署可以省去您工程配置的时间。联盟iOS SDK会通过CocoaPods进行发布,推荐您使用自动部署。
安装CocoaPods
CocoaPods是一个Swift和Objective-C项目的依赖管理器。它拥有超过49,000个第三方库,超过3,000,000个app都在使用cocoaPods做依赖管理,CocoaPods可以帮助你优雅的扩展你的项目。 如果您未安装过cocoaPods,可以通过以下命令行进行安装。更多详情请访问CocoaPods官网。
xxxxxxxxxx$ sudo gem install cocoapods
注意:安装过程可能会耗时比较长,也有可能收到网络状况导致失败,请多次尝试直到安装成功。
配置Podfile文件
在您的工程文件所在文件夹下有一个名为Podfile的文件。如果您第一次使用CocoaPods,可以在通过以下命令初始化一个Podfile文件:
xxxxxxxxxx$ pod init
打开Podfile文件,应该是如下内容(具体内容可能会有一些出入):
xxxxxxxxxx# platform :ios, '9.0'target 'podTest' do# use_frameworks!# Pods for podTestend
修改Podfile文件,将pod 'GDTMobSDK'添加到Podfile中,如下所示:
xxxxxxxxxx# platform :ios, '9.0'target 'podTest' do# use_frameworks!pod 'GDTMobSDK', '~> 4.8.1' # 输入你想要的版本号# Pods for podTestend
使用CocoaPods进行SDK部署
通过CocoaPods安装联盟SDK前,确保CocoaPods索引已经更新。可以通过运行以下命令来更新索引:
xxxxxxxxxx$ pod repo update
运行命令进行安装:
xxxxxxxxxx$ pod install
也可以将上述两条命令合成为如下命令:
xxxxxxxxxx$ pod install --repo-update
命令执行成功后,会生成.xcworkspace文件,可以打开.xcworkspace来启动工程,如下图所示。

升级联盟SDK
升级SDK时,首先要更新repo库,执行命令:
xxxxxxxxxx$ pod repo update
之后重新执行如下命令进行安装即可升级至最新版SDK
xxxxxxxxxx$ pod install
注意 :只有在Podfile文件中没有指定SDK版本时,运行上述命令才会自动升级到最新版本。不然需要修改Podfile文件,手动指定SDK版本为最新版本。
指定联盟SDK版本
指定联盟SDK版本前,请先确保repo库为最新版本,参考上一小节内容进行更新。如果需要指定联盟SDK版本,需要在Podfile文件中,pod那一行指定版本号:
xxxxxxxxxxpod 'GDTMobSDK', '~> 4.8.1' #这里改成你想要的版本号
之后运行命令:
xxxxxxxxxx$ pod install
本章会指导您手动将联盟iOS SDK进行集成。如果您没有项目,请先创建一个空白项目。
将解压缩后的lib文件copy到工程文件夹中,然后在项目中选中项目文件,选择Add Files to “your project name”:

在弹出来的窗口中,请将如下文件添加到工程中:

| 需要引入的依赖库 |
|---|
| libGDTMobSDK.a |
| GDTMobBannerView.h |
| GDTNativeExpressAd.h |
| GDTNativeExpressAdView.h |
| GDTMobInterstitial.h |
| GDTNativeAd.h |
| GDTSplashAd.h |
| GDTRewardVideo.h |
| GDTSDKDefines.h |
| 库名称 | SDK | 备注 |
|---|---|---|
| AdSupport.framework | 4.7.2及以后版本 | |
| CoreLocation.framework | 同上 | |
| QuartzCore.framework | 同上 | |
| SystemConfiguration.framework | 同上 | |
| CoreTelephony.framework | 同上 | |
| libz.tbd | 同上 | 或者是libz.dylib |
| Security.framework | 同上 | |
| StoreKit.framework | 同上 | |
| libxml2.tbd | 同上 | |
| AVFoundation.framework | 同上 | |
| WebKit.framework | 同上 | 可选 |
说明:
- SystemConfiguration.framework、CoreTelephony.framework、Security.framework是为了统计app信息使用
- iOS9以后的版本,需要把libz.dylib替换成libz.tbd
- 引入系统库的操作过程如下: 在Xcode中选中工程名,在Target->Build Phases->Link Binary With Libraries中点击“+”,在弹出窗口输入库名称,出现后点击“Add”则将库引入到系统中。
在Target->Build Settings -> Other Linker Flags中添加-ObjC, 字母o和c大写。

GDTMobSample-Swift-Bridging-Header.h。在这个文件中import我们需要的所有头文件,代码如下:xxxxxxxxxx#import "GDTNativeExpressAdView.h"#import "GDTMobBannerView.h"#import "GDTMobInterstitial.h"#import "GDTNativeExpressAd.h"#import "GDTNativeAd.h"#import "GDTSplashAd.h"#import "GDTSDKConfig.h"

苹果公司在iOS9中升级了应用网络通信安全策略,默认推荐开发者使用HTTPS协议来进行网络通信,并限制HTTP协议的请求。为了避免出现无法拉取到广告的情况,我们推荐开发者在info.plist文件中增加如下配置来实现广告的网络访问:(信任HTTP请求)

若开发者有使用HTTPS进行应用内网络访问的场景需要,可以调用腾讯广告联盟提供的接口。
xxxxxxxxxx若有获取SDK版本的需求,也可直接调用接口:###### Objective-C```objective-cNSString *version = [GDTSDKConfig sdkVersion];
xxxxxxxxxxlet version = GDTSDKConfig.sdkVersion()本章内容将指导您在您的iOS应用中插入Banner广告。Banner广告API可以帮助您快速在iOS应用中插入一条banner广告,您无需手动设置广告的title、图片url甚至于关闭按钮,唯一需要提供的就是广告的APPID和PLACEMENTID。
Banner 广告分为文字链、纯图片和图文描述:
| 文字链 | 纯图片 | 图文描述 |
|---|---|---|
![]() | ![]() | ![]() |
联盟广告推荐您将Banner设置为以下尺寸:
| 尺寸(宽x高) | 说明 | 适用设备 | GDT_AD 常量 |
|---|---|---|---|
| 300x50 | 标准Banner广告 | 手机 | GDTMOB_AD_SUGGEST_SIZE_320x50 |
| 468x60 | 标准Banner广告 | 平板电脑 | GDTMOB_AD_SUGGEST_SIZE_468x60 |
| 300x50 | 大型Banner广告 | 平板电脑 | GDTMOB_AD_SUGGEST_SIZE_728x90 |
说明:
开发者在嵌入Banner时,可以手动设置Banner条的宽度用来满足场景需求,而高度的话不建议更改,否则显示效果会有影响。
打开GPS精准广告定位开关,可以借助获取的地理位置开关,提高广告填充率,增加广告收益。建议打开开关。
xxxxxxxxxxself.bannerView.isGpsOn = YES;
xxxxxxxxxxbannerView.isGpsOn = true
说明:
如果GPS精准广告定位功能与本身应用功能相矛盾也存在被苹果审核拒绝的风险。
您可以实现全部或部分GDTMobBannerViewDelegate,以跟踪点击成功或者Banner请求失败等广告生命周期事件。
xxxxxxxxxx@protocol GDTMobBannerViewDelegate <NSObject>@optional- (void)bannerViewMemoryWarning;- (void)bannerViewDidReceived;- (void)bannerViewFailToReceived:(NSError *)error;- (void)bannerViewWillLeaveApplication;- (void)bannerViewWillClose;- (void)bannerViewWillExposure;- (void)bannerViewClicked;- (void)bannerViewWillPresentFullScreenModal;- (void)bannerViewDidPresentFullScreenModal;- (void)bannerViewWillDismissFullScreenModal;- (void)bannerViewDidDismissFullScreenModal;@end
在实现上述事件回调之前,请务必先设置delegate:
xxxxxxxxxxbannerView.delegate = self;
xxxxxxxxxxbannerView.delegate = self
| 回调函数名 | 回调函数含义 |
|---|---|
| bannerViewMemoryWarning | 当bannerView收到内存警告时回调 |
| bannerViewDidReceived | 请求广告条数据失败后调用 |
| bannerViewFailToReceived | 请求广告条数据失败后调用 |
| bannerViewWillLeaveApplication | 应用进入后台时调用 |
| bannerViewWillClose | banner条被用户关闭时调用 |
| bannerViewWillExposure | banner条曝光回调 |
| bannerViewClicked | banner条点击回调 |
| bannerViewWillPresentFullScreenModal | banner广告点击以后即将弹出全屏广告页 |
| bannerViewDidPresentFullScreenModal | banner广告点击以后弹出全屏广告页完毕 |
| bannerViewWillDismissFullScreenModal | 全屏广告页即将被关闭 |
| bannerViewDidDismissFullScreenModal | 全屏广告页已经被关闭 |
xxxxxxxxxx @interface BannerViewController: UIViewController <GDTMobBannerViewDelegate> @property (nonatomic, strong) GDTMobBannerView *bannerView;xxxxxxxxxx class BannerViewController: UIViewController,GDTMobBannerViewDelegate { private var bannerView:GDTMobBannerView! ... }xxxxxxxxxx- (void)viewDidLoad{[super viewDidLoad];CGRect rect = {CGPointZero, GDTMOB_AD_SUGGEST_SIZE_320x50};_bannerView = [[GDTMobBannerView alloc] initWithFrame:rect appId:YOUR_APP_ID placementId:YOUR_PLACEMENT_ID];//设置当前的ViewController_bannerView.currentViewController = self;//设置广告轮播时间,范围为30-120秒,0表示不轮播_bannerView.interval = 30;//开启bnner轮播时的动画效果。默认开启。_bannerView.isAnimationOn = self.animationSwitch.on;//展示关闭按钮,默认展示。_bannerView.showCloseBtn = self.closeBtnSwitch.on;//开启GPS定位,默认关闭。_bannerView.isGpsOn = self.gpsSwitch.on;//设置Delegate_bannerView.delegate = self;}
xxxxxxxxxxoverride func viewDidLoad() {super.viewDidLoad()let rect = CGRect.init(origin: .zero, size:CGSize.init(width: 320, height: 50))bannerView = GDTMobBannerView.init(frame: rect, appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID)bannerView.currentViewController = selfbannerView.interval = Int32(refreshIntervalText.text!)!bannerView.isAnimationOn = animationSwitch.isOnbannerView.showCloseBtn = closeBtnSwitch.isOnbannerView.isGpsOn = gpsSwitch.isOnbannerView.delegate = self}
xxxxxxxxxx- (void)clickRemoveAd:(id)sender {[self.bannerView removeFromSuperview];self.bannerView = nil;}- (void)clickLoadAd:(id)sender {[self clickRemoveAd:nil];[self.view addSubview:self.bannerView];//Layout your frame,可以使用 Auto Layout 布局,也可使用 frame 布局。[self.bannerView loadAdAndShow];}
xxxxxxxxxxfunc clickRemoveAd(_ sender: Any) {removeAdFromSuperview()}private func removeAdFromSuperview() {if let view = bannerView {view.removeFromSuperview()bannerView = nil}}@IBAction func clickLoadAd(_ sender: Any) {removeAdFromSuperview()loadAd()}@IBAction func loadAd() {initMobBannerView()self.view.addSubview(bannerView)bannerView.translatesAutoresizingMaskIntoConstraints = false//Layout your frame,可以使用 Auto Layout 布局,也可使用 frame 布局。self.bannerView.loadAdAndShow()}
说明:
在释放bannerView之前,建议在先将bannerView对象的delegate和currentViewController属性置为空,然后再释放bannerView。
开启GPS定位可以获取地理位置信息,提高广告填充率,增加收益,但是如果与本身应用功能相矛盾也存在被苹果审核拒绝的风险。
在以下情况下使用Banner广告请将interval刷新频率设为0,即不自动刷新。
- 使用广告聚合平台控制刷新频率时。
- 使用代码定时新建GDTMobBannerView来控制刷新频率时。
在您的ViewController里实现如下回调,处理Banner广告加载失败的问题:
xxxxxxxxxx- (void)bannerViewFailToReceived:(NSError *)error{NSLog(@"banner failed to Received : %@",error);}
xxxxxxxxxxfunc bannerViewFail(toReceived error: Error!) {print(#function,error)}
插屏广告是一种可以在应用中叠加显示的全屏广告,视觉效果震撼,它们通常用在正常的应用过渡点展示。请按照本章内容来展示此类广告。
| 小规格图文(弹窗) | 小规格纯图片(弹窗) | 大规格纯图片(竖屏) |
|---|---|---|
![]() | ![]() | ![]() |
您可以实现全部或部分GDTMobInterstitialDelegate,以跟踪点击成功或者插屏广告请求失败等广告生命周期事件。
xxxxxxxxxx@protocol GDTMobInterstitialDelegate <NSObject>@optional- (void)interstitialSuccessToLoadAd;- (void)interstitialFailToLoadAd:error;- (void)interstitialWillPresentScreen;- (void)interstitialDidPresentScreen;- (void)interstitialDidDismissScreen;- (void)interstitialApplicationWillEnterBackground;- (void)interstitialWillExposure;- (void)interstitialClicked;- (void)interstitialAdWillPresentFullScreenModal;- (void)interstitialAdDidPresentFullScreenModal;- (void)interstitialAdWillDismissFullScreenModal;- (void)interstitialAdDidDismissFullScreenModal;@end
在实现上述事件回调之前,请务必先设置delegate:
xxxxxxxxxxself.interstitial.delegate = self;
xxxxxxxxxxinterstitial.delegate = self
回调函数列表
| 回调函数名 | 回调函数含义 |
|---|---|
| interstitialSuccessToLoadAd | 插屏广告预加载成功回调 |
| interstitialFailToLoadAd | 插屏广告预加载失败回调 |
| interstitialWillPresentScreen | 插屏广告将要展示回调 |
| interstitialDidPresentScreen | 插屏广告视图展示成功回调 |
| interstitialDidDismissScreen | 插屏广告展示结束回调 |
| interstitialApplicationWillEnterBackground | 应用进入后台时回调 |
| interstitialWillExposure | 插屏广告曝光回调 |
| interstitialClicked | 插屏广告点击回调 |
| interstitialAdWillPresentFullScreenModal | 点击插屏广告以后即将弹出全屏广告页 |
| interstitialAdDidPresentFullScreenModal | 点击插屏广告以后弹出全屏广告页 |
| interstitialAdWillDismissFullScreenModal | 全屏广告页将要关闭 |
| interstitialAdDidDismissFullScreenModal | 全屏广告页被关闭 |
打开GPS精准广告定位开关,可以借助获取的地理位置开关,提高广告填充率,增加广告收益。建议打开开关。
self.interstitial.isGpsOn = YES;
interstitial.isGpsOn = true
说明:
如果GPS精准广告定位功能与本身应用功能相矛盾也存在被苹果审核拒绝的风险。
#import "GDTMobInterstitial.h" @interface InterstitialViewController() <GDTMobInterstitialDelegate> @property (nonatomic, strong) GDTMobInterstitial *interstitial;
class InterstitialViewController: UIViewController,GDTMobInterstitialDelegate {
private var interstitial: GDTMobInterstitial?
...
}
- (IBAction)loadAd:(id)sender {
if(self.interstitial) {
self.interstitial.delegate = nil;
}
self.interstitial = [[GDTMobInterstitial alloc] initWithAppId:YOUR_APP_ID placementId:YOUR_PLACEMENT_ID];
self.interstitial.delegate = self;
//预加载广告
[self.interstitial loadAd];
}
- (IBAction)showAd:(id)sender
{
[self.interstitial presentFromRootViewController:self];
}
@IBAction func loadAd(_ sender: Any) {
if (interstitial != nil) {
interstitial?.delegate = nil
interstitial = nil
}
interstitial = GDTMobInterstitial.init(appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID)
interstitial?.delegate = self
interstitial?.loadAd()
}
@IBAction func showAd(_ sender: Any) {
interstitial?.present(fromRootViewController: self)
}
注意:
- 在一次展现完成后,需要再次调用loadAd方法来加载新的广告,用于下次展现。
- 关于释放,建议在释放ViewController之前将_interstitialObj的delegate属性设置为nil
在您的ViewController里实现如下回调,处理插屏广告加载失败的问题:
- (void)interstitialFailToLoadAd:(GDTMobInterstitial *)interstitial error:(NSError *)error
{
NSLog(@"interstitial fail to load, Error : %@",error);
}
func interstitialFail(toLoadAd interstitial: GDTMobInterstitial!, error: Error!) {
print(#function,error)
}
开屏广告会在您的应用开启时加载,拥有固定展示时间(一般为5秒),展示完毕后自动关闭并进入您的应用主界面。请按照本章内容来展示此类广告。
| 半屏 | 全屏 |
|---|---|
![]() | ![]() |
您可以实现全部或部分GDTSplashAdDelegate,以跟踪点击成功或者插屏广告请求失败等广告生命周期事件。
@protocol GDTSplashAdDelegate <NSObject> @optional - (void)splashAdSuccessPresentScreen; - (void)splashAdFailToPresent:error; - (void)splashAdApplicationWillEnterBackground; - (void)splashAdExposured; - (void)splashAdClicked; - (void)splashAdWillClosed; - (void)splashAdClosed; - (void)splashAdWillPresentFullScreenModal; - (void)splashAdDidPresentFullScreenModal; - (void)splashAdWillDismissFullScreenModal; - (void)splashAdDidDismissFullScreenModal; - (void)splashAdLifeTime; @end
在实现上述事件回调之前,请务必先设置delegate:
self.splashAd.delegate = self;
splashAd.delegate = self
回调函数列表
| 回调函数名 | 回调函数含义 |
|---|---|
| splashAdSuccessPresentScreen | 开屏广告成功展示 |
| splashAdFailToPresent | 开屏广告展示失败 |
| splashAdApplicationWillEnterBackground | 应用进入后台时回调 |
| splashAdExposured | 开屏广告曝光回调 |
| splashAdClicked | 开屏广告点击回调 |
| splashAdWillClosed | 开屏广告将要关闭回调 |
| splashAdClosed | 开屏广告关闭回调 |
| splashAdWillPresentFullScreenModal | 开屏广告点击以后即将弹出全屏广告页 |
| splashAdDidPresentFullScreenModal | 开屏广告点击以后弹出全屏广告页 |
| splashAdWillDismissFullScreenModal | 点击以后全屏广告页将要关闭 |
| splashAdDidDismissFullScreenModal | 点击以后全屏广告页已经关闭 |
| splashAdLifeTime | 开屏广告剩余时间回调 |
您可以设置拉取广告的超时时间,默认为3秒。通常情况,开发者调用loadAd后会展示backgroundColor,如果在该时间内广告拉取成功,则显示开屏广告;否则放弃本次广告展示。
self.splashAd.fetchDelay = 5;
splashAd.fetchDelay = 5
#import "GDTSplashAd.h" @interface GDTAppDelegate : UIResponder <UIApplicationDelegate,GDTSplashAdDelegate> @property (strong, nonatomic) GDTSplashAd *splash; @property (retain, nonatomic) UIView *bottomView; @end
class SplashViewController: UIViewController,GDTSplashAdDelegate {
private var splashAd: GDTSplashAd!
private var bottomView: UIView!
...
}
GDTSplashAd *splash = [[GDTSplashAd alloc] initWithAppkey: YOUR_APP_ID placementId:YOUR_PLACEMENT_ID];
splash.delegate = self; //设置代理
//根据iPhone设备不同设置不同背景图
if ([[UIScreen mainScreen] bounds].size.height >= 568.0f) {
splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LaunchImage-568h"]];
} else {
splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LaunchImage"]];
}
splash.fetchDelay = 3; //开发者可以设置开屏拉取时间,超时则放弃展示
//[可选]拉取并展示全屏开屏广告
//[splashAd loadAdAndShowInWindow:self.window];
//设置开屏底部自定义LogoView,展示半屏开屏广告
_bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 100)];
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SplashBottomLogo"]];
[_bottomView addSubview:logo];
logo.center = _bottomView.center;
_bottomView.backgroundColor = [UIColor whiteColor];
splashAd = GDTSplashAd.init(appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID)
splashAd.delegate = self
splashAd.fetchDelay = 3
var splashImage = UIImage.init(named: "SplashNormal")
if Util.isIphoneX() {
splashImage = UIImage.init(named: "SplashX")
} else if Util.isSmallIphone() {
splashImage = UIImage.init(named: "SplashSmall")
}
splashAd.backgroundImage = splashImage
bottomView = UIView.init(frame: CGRect(origin: CGPoint.zero, size: CGSize(width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.height * 0.25)))
bottomView.backgroundColor = .white
let logo = UIImageView.init(image: UIImage.init(named: "SplashLogo"))
logo.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 311, height: 47))
logo.center = bottomView.center
bottomView.addSubview(logo)
let window = UIApplication.shared.keyWindow
splashAd.loadAndShow(in: window, withBottomView: bottomView, skip: nil)
说明:
目前腾讯广告联盟开屏广告只针对iPhone设备在垂直方向上展示。
在您的ViewController里实现如下回调,处理开屏广告加载失败的问题:
- (void)splashAdFailToPresent:(GDTSplashAd *)splashAd
withError:(NSError *)error
{
NSLog(@"%s%@",__FUNCTION__,error);
}
func splashAdFail(toPresent splashAd: GDTSplashAd!, withError error: Error!) {
print(#function,error)
}
说明:开屏广告只支持竖屏使用。
原生模板广告是腾讯广告联盟推出的一种自动化展现的原生广告,图文广告零门槛不需要申请权限就可以使用,视频广告需要申请对应的权限。开通对应的权限后,在新建广告位时支持只出图文广告或只出视频广告,也支持图文和视频广告混出。但为了保证广告位的填充率,当您有接入视频广告需求的时候,建议尽量选择图文和视频广告混出。
原生广告(模板方式)有七种广告样式可选:
| 上图下文 (图片尺寸1280×720) | 上文下图 (图片尺寸1280×720) | 左图右文 (图片尺寸1200×800) | 左文右图 (图片尺寸1200×800) |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
| 双图双文 (大图尺寸1280×720) | 纯图片 (图片尺寸800×1200) | 纯图片 (图片尺寸1280×720) |
|---|---|---|
![]() | ![]() | ![]() |
目前,腾讯广告联盟支持自主调整已创建的原生模板广告的模板参数,腾讯联盟开发者平台操作入口:【我的广告位】--- 原生模板广告位:【修改】--- 广告样式:【修改】
自定义模板调参标准如下:
| 左文右图/ 左图右文 | 上图下文/ 上文下图 | 双图双文 | 纯图片 | |
|---|---|---|---|---|
| 图片(广告元素) | 300>图片宽度>30 300>图片高度>30 | 横图:宽高比在40%-79%之间(高/宽) | 横图:宽高比在40%-79%之间(高/宽) | 横图:宽高比在40%-79%之间(高/宽) |
| 标题(广告元素) | 颜色、大小(>0) 上下左右边距(>0) | 颜色、大小(>0) 上下左右边距(>0) | 颜色、大小(>0) 上下左右边距(>0) | 无 |
| 描述(广告元素) | 颜色、大小(>0) 上下左右边距(>0) | 颜色、大小(>0) 上下左右边距(>0) | 颜色、大小(>0) 上下左右边距(>0) | 无 |
| 关闭按钮(互动) | 有无 | 有无 | 有无 | |
| 背景 | 颜色(按照 RGB 标准) | 颜色(按照 RGB 标准) | 颜色(按照 RGB 标准) | 颜色(按照 RGB 标准) |
| 按钮(互动) | 无 | 无 | 背景颜色、边框颜色、字体颜色、字体大小(>0) | 无 |
注意:以下接入代码示例只适用于原生模板广告位。误用其他广告位 ID 使用原生模板广告的接口,则会导致无广告返回。
您可以实现全部或部分GDTNativeExpressAdDelegate,以跟踪点击成功或者插屏广告请求失败等广告生命周期事件。
@protocol GDTNativeExpressAdDelegete <NSObject> @optional - (void)nativeExpressAdSuccessToLoad:views; - (void)nativeExpressAdFailToLoad: error; - (void)nativeExpressAdViewRenderSuccess; - (void)nativeExpressAdViewRenderFail; - (void)nativeExpressAdViewExposure; - (void)nativeExpressAdViewClicked; - (void)nativeExpressAdViewClosed; - (void)nativeExpressAdViewWillPresentScreen; - (void)nativeExpressAdViewDidPresentScreen; - (void)nativeExpressAdViewWillDissmissScreen; - (void)nativeExpressAdViewDidDissmissScreen; - (void)nativeExpressAdViewApplicationWillEnterBackground; - (void)nativeExpressAdView:playerStatusChanged; - (void)nativeExpressAdViewWillPresentVideoVC; - (void)nativeExpressAdViewDidPresentVideoVC; - (void)nativeExpressAdViewWillDismissVideoVC; - (void)nativeExpressAdViewDidDismissVideoVC; @end
在实现上述事件回调之前,请务必先设置delegate:
self.nativeExpressAd.delegate = self;
nativeExpressAd.delegate = self
回调函数列表
| 回调函数名 | 回调函数含义 |
|---|---|
| nativeExpressAdSuccessToLoad:views | 拉取原生模板广告成功 |
| nativeExpressAdFailToLoad:error | 拉取原生模板广告失败 |
| nativeExpressAdViewRenderSuccess | 原生模板广告渲染成功 |
| nativeExpressAdViewRenderFail | 原生模板广告渲染失败 |
| nativeExpressAdViewExposure | 原生模板广告曝光回调 |
| nativeExpressAdViewClicked | 原生模板广告点击回调 |
| nativeExpressAdViewClosed | 原生模板广告被关闭 |
| nativeExpressAdViewWillPresentScreen | 点击原生模板广告,即将弹出全屏广告页 |
| nativeExpressAdViewDidPresentScreen | 点击原生模板广告,弹出全屏广告页 |
| nativeExpressAdViewWillDissmissScreen | 全屏广告页将要关闭 |
| nativeExpressAdViewDidDissmissScreen | 全屏广告页将要关闭 |
| nativeExpressAdViewApplicationWillEnterBackground | 原生模板广告点击后应用进后台 |
| nativeExpressAdView:playerStatusChanged | 原生模板视频广告 player 播放状态更新回调 |
| nativeExpressAdViewWillPresentVideoVC | 原生视频模板详情页将要展示 |
| nativeExpressAdViewDidPresentVideoVC | 原生视频模板详情页已经展示 |
| nativeExpressAdViewWillDismissVideoVC | 原生视频模板详情页将要消失 |
| nativeExpressAdViewDidDismissVideoVC | 原生视频模板详情页已经消失 |
其中,视频播放过程中,会有如下几种状态
| 枚举变量 | 枚举含义 |
|---|---|
| GDTMediaPlayerStatusInitial | 初始状态 |
| GDTMediaPlayerStatusLoading | 加载中 |
| GDTMediaPlayerStatusStarted | 开始播放 |
| GDTMediaPlayerStatusPaused | 用户行为导致暂停 |
| GDTMediaPlayerStatusStoped | 播放停止 |
| GDTMediaPlayerStatusError | 播放出错 |
#import "GDTNativeExpressAd.h" #import "GDTNativeExpressAdView.h" @interface NativeExpressAdViewController : UIViewController <GDTNativeExpressAdDelegete> @property (nonatomic, strong) NSArray *expressAdViews; @property (nonatomic, strong) GDTNativeExpressAd *nativeExpressAd;
UIViewController,UITableViewDelegate,UITableViewDataSource,GDTNativeExpressAdDelegete {
private var expressAdViews:Array<GDTNativeExpressAdView>!
private var nativeExpressAd:GDTNativeExpressAd!
...
}
- (void)viewDidLoad
{
[super viewDidLoad];
// 支持视频广告的 PlacementId 会混出视频与图片广告
self.nativeExpressAd = [[GDTNativeExpressAd alloc] initWithAppId:@"YOUR_APP_ID" placementId:@"YOUR_PLACEMENT_ID" adSize:CGSizeMake(self.widthSlider.value, self.heightSlider.value)];
self.nativeExpressAd.delegate = self;
// 配置视频播放属性
self.nativeExpressAd.videoAutoPlayOnWWAN = self.videoAutoPlaySwitch.on;
self.nativeExpressAd.videoMuted = self.videoMutedSwitch.on;
[self.nativeExpressAd loadAd:(int)self.adCountSlider.value];
}
override func viewDidLoad() {
super.viewDidLoad()
nativeExpressAd = GDTNativeExpressAd.init(appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID, adSize: CGSize(width: Int(widthSlider.value), height: Int(heightSlider.value)))
nativeExpressAd.delegate = self
nativeExpressAd.videoAutoPlayOnWWAN = videoAutoPlaySwitch.isOn
nativeExpressAd.videoMuted = videoMutedSwitch.isOn
nativeExpressAd.load(Int(adCountSlider.value))
}
- (void)nativeExpressAdSuccessToLoad:(GDTNativeExpressAd
*)nativeExpressAd views:(NSArray<__kindof
GDTNativeExpressAdView *> *)views
{
self.expressAdViews = [NSArray arrayWithArray:views];
if (self.expressAdViews.count) {
[self.expressAdViews enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
GDTNativeExpressAdView *expressView = (GDTNativeExpressAdView *)obj;
expressView.controller = self;
[expressView render];
}];
}
// 广告位 render 后刷新 tableView
[self.tableView reloadData];
}
func nativeExpressAdSuccess(toLoad nativeExpressAd: GDTNativeExpressAd!, views: [GDTNativeExpressAdView]!) {
expressAdViews = Array.init(views)
if expressAdViews.count > 0 {
for obj in expressAdViews {
let expressView:GDTNativeExpressAdView = obj
expressView.controller = self
expressView.render()
}
}
tableView.reloadData()
}
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row % 2 == 0) {
// cell 高度取 adView render 后的值,这里的值是SDK算出来的
UIView *view = [self.expressAdViews objectAtIndex:indexPath.row / 2];
return view.bounds.size.height;
} else {
return 44;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row % 2 == 0) {
cell = [self.tableView dequeueReusableCellWithIdentifier:@"nativeexpresscell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *subView = (UIView *)[cell.contentView viewWithTag:1000];
if ([subView superview]) {
[subView removeFromSuperview];
}
UIView *view = [self.expressAdViews objectAtIndex:indexPath.row / 2];
view.tag = 1000;
[cell.contentView addSubview:view];
} else {
cell = [self.tableView dequeueReusableCellWithIdentifier:@"splitnativeexpresscell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor grayColor];
}
return cell;
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row % 2 == 0 {
let view: UIView = expressAdViews[indexPath.row/2]
return view.bounds.size.height
}
return 44
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell:UITableViewCell!
if indexPath.row % 2 == 0 {
cell = tableView.dequeueReusableCell(withIdentifier: "nativeexpresscell", for: indexPath)
cell.selectionStyle = .none
let subView: UIView? = cell!.contentView.viewWithTag(1000)
if (subView?.superview != nil) {
subView?.removeFromSuperview()
}
let view: UIView = expressAdViews[indexPath.row / 2]
view.tag = 1000
cell.contentView.addSubview(view)
} else {
cell = tableView.dequeueReusableCell(withIdentifier: "splitnativeexpresscell", for: indexPath)
cell.backgroundColor = .gray
}
return cell
}
在您的ViewController里实现如下回调,处理原生模板广告加载失败的问题:
- (void)nativeExpressAdRenderFail:(GDTNativeExpressAdView
*)nativeExpressAdView
{
NSLog(@"Express Ad Render Fail");
}
- (void)nativeExpressAdFailToLoad:(GDTNativeExpressAd *)nativeExpressAd error:(NSError *)error
{
NSLog(@"Express Ad Load Fail : %@",error);
}
func nativeExpressAdFail(toLoad nativeExpressAd: GDTNativeExpressAd!, error: Error!) {
print("Express Ad Load Fail : \(error)")
}
func nativeExpressAdViewRenderFail(_ nativeExpressAdView: GDTNativeExpressAdView!) {
print(#function)
}
使用原生广告的API,您可以为您的应用打造定制式体验。在使用原生广告的API时,您会收到一组相关属性(图标、图片、广告标题、广告描述等)。 一条典型的广告包含如下字段,如有需要您可以创建以下字段相关视图:

除此之外,开发者还可以拿到应用类广告的星级、应用类广告的价格、以及三小图广告的图片集合。
具体字段在GDTNativeAdData,其含义如下表所示:
| 键 | 描述 |
|---|---|
| GDTNativeAdDataKeyTitle | 广告标题 |
| GDTNativeAdDataKeyDesc | 广告描述 |
| GDTNativeAdDataKeyIconUrl | 广告图标URL |
| GDTNativeAdDataKeyImgUrl | 广告详情图URL |
| GDTNativeAdDataKeyAppRating | 应用类广告的星级数据 |
| GDTNativeAdDataKeyAppPrice | 应用类广告的价格数据 |
| GDTNativeAdDataKeyImgList | 三小图广告的图片集合 |
您可以实现全部或部分GDTNativeAdDelegate,以跟踪点击成功或者原生广告请求失败等广告生命周期事件。
@protocol GDTNativeAdDelegate <NSObject> - (void)nativeAdSuccessToLoad:(NSArray *)nativeAdDataArray; - (void)nativeAdFailToLoad:(NSError *)error; @optional - (void)nativeAdWillPresentScreen; - (void)nativeAdApplicationWillEnterBackground; - (void)nativeAdClosed; @end
在实现上述事件回调之前,请务必先设置delegate:
self.nativeAd.delegate = self;
nativeAd.delegate = self
回调函数列表
| 回调函数名 | 回调函数含义 |
|---|---|
| nativeAdSuccessToLoad | 原生广告加载广告数据成功回调 |
| nativeAdFailToLoad | 原生广告加载广告数据失败回调 |
| nativeAdWillPresentScreen | 原生广告点击之后回调 |
| nativeAdApplicationWillEnterBackground | 原生广告点击之后应用进入后台时回调 |
| nativeAdClosed | 原生广告点击以后浏览器被关闭时回调 |
#import "GDTNativeAd.h" @interface NativeViewController ()<GDTNativeAdDelegate> @property (nonatomic, strong) GDTNativeAd *nativeAd; @property (nonatomic, strong) NSArray *adArray; @property (nonatomic, strong) GDTNativeAdData *currentAdData;
class NativeViewController: UIViewController,GDTNativeAdDelegate {
var nativeAd:GDTNativeAd!
var adArray:Array<GDTNativeAdData>!
var currentAdData:GDTNativeAdData!
var adView:UIView!
var attached:Bool = false
...
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.nativeAd = [[GDTNativeAd alloc] initWithAppId:@"YOUR_APP_ID" placementId:@"YOUR_PLACEMENT_ID"];
self.nativeAd.controller = self;
self.nativeAd.delegate = self;
[self.nativeAd loadAd:1];
}
override func viewDidLoad() {
super.viewDidLoad()
self.nativeAd = GDTNativeAd.init(appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID)
self.nativeAd.controller = self
self.nativeAd.delegate = self
self.nativeAd.load(1)
}
-(void)nativeAdSuccessToLoad:(NSArray *)nativeAdDataArray
{
/*广告数据拉取成功,存储并展示*/
self.adArray = nativeAdDataArray;
dispatch_async(dispatch_get_main_queue(), ^{
...
});
}
func nativeAdSuccess(toLoad nativeAdDataArray: [Any]!) {
print(#function)
self.adArray = nativeAdDataArray as! Array<GDTNativeAdData>
DispatchQueue.main.async {
...
}
}
在您的ViewController里实现如下回调,处理原生广告加载失败的问题:
- (void)nativeAdFailToLoad:(NSError *)error
{
NSLog(@"%@",error);
/*广告数据拉取失败*/
dispatch_async(dispatch_get_main_queue(), ^{
...
});
}
func nativeAdFail(toLoad error: Error!) {
print(error)
DispatchQueue.main.async {
...
}
}
说明:
- 建议在释放原生广告 GDTNativeAd 对象之前将 GDTNativeAd 对象的 delegate 属性设置为nil.
- 当用户点击广告弹出内置目标页时,请勿释放 GDTNativeAd 实例。
- 广告从拉取到曝光超过45分钟,将作为无效曝光。
- 广告从拉取到点击超过90分钟,将作为无效点击,不会进行计费。
- 广告数据渲染完毕,即将展示时需调用 AttachAd 方法,否则将不会产生曝光记录,也无法进行计费。
激励视频广告是一种常见于游戏内的广告样式。用户通过开发者提供的入口,全屏观看完整视频,获得相应的奖励。目前的视频包括横版及竖版2种样式,您可以根据需要创建对应的广告位。样式图如下: (目前激励视频需要开通相应的权限,才可以创建激励视频样式的广告位):
| 竖屏广告 | 横屏广告 |
|---|---|
![]() | ![]() |
您可以实现全部或部分GDTRewardedVideoAdDelegate,以跟踪点击成功或者激励视频广告请求失败等广告生命周期事件。
@protocol GDTRewardedVideoAdDelegate <NSObject> @optional - (void)gdt_rewardVideoAdDidLoad:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdVideoDidLoad:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdWillVisible:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdDidExposed:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdDidClose:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdDidClicked:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:(NSError *)error; - (void)gdt_rewardVideoAdDidRewardEffective:(GDTRewardVideoAd *)rewardedVideoAd; - (void)gdt_rewardVideoAdDidPlayFinish:(GDTRewardVideoAd *)rewardedVideoAd; @end
在实现上述事件回调之前,请务必先设置delegate:
self.rewardVideoAd.delegate = self;
rewardVideoAd.delegate = self
回调函数列表
| 回调函数名 | 回调函数含义 |
|---|---|
| gdt_rewardVideoAdDidLoad | 激励视频广告加载广告数据成功回调 |
| gdt_rewardVideoAdVideoDidLoad | 激励视频数据下载成功回调,已经下载过的视频会直接回调 |
| gdt_rewardVideoAdWillVisible | 激励视频播放页即将展示回调 |
| gdt_rewardVideoAdDidExposed | 激励视频广告曝光回调 |
| gdt_rewardVideoAdDidClose | 激励视频广告播放页关闭回调 |
| gdt_rewardVideoAdDidClicked | 激励视频广告信息点击回调 |
| gdt_rewardVideoAd:didFailWithError | 激励视频广告各种错误信息回调 |
| gdt_rewardVideoAdDidRewardEffective | 激励视频广告播放达到激励条件回调,以此回调作为奖励依据 |
| gdt_rewardVideoAdDidPlayFinish | 激励视频广告播放完成回调 |
#import "GDTRewardVideo.h" @interface RewardVideoViewController ()<GDTRewardedVideoAdDelegate> @property (nonatomic, strong) GDTRewardVideo *rewardVideoAd;
class RewardVideoViewController: UIViewController,GDTRewardedVideoAdDelegate {
var rewardVideoAd:GDTRewardVideo!
...
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.rewardVideoAd = [[GDTRewardVideo alloc] initWithAppId:@"YOUR_APP_ID" placementId:@"YOUR_PLACEMENT_ID"];
self.rewardVideoAd.delegate = self;
[self.rewardVideoAd loadAd];
}
override func viewDidLoad() {
super.viewDidLoad()
self.rewardVideoAd = GDTRewardVideo.init(appId: YOUR_APP_ID, placementId: YOUR_PLACEMENT_ID)
self.rewardVideoAd.delegate = self
self.rewardVideoAd.load()
}
- (void)gdt_rewardVideoAdVideoDidLoad:(GDTRewardVideoAd *)rewardedVideoAd
{
NSLog(@"视频文件加载成功");
}
// 确认激励视频广告有效性之后,在合适的时机展示广告
- (IBAction)playVideo:(UIButton *)sender {
if (self.rewardVideoAd.expiredTimestamp <= [[NSDate date] timeIntervalSince1970]) {
self.statusLabel.text = @"广告已过期,请重新拉取";
return;
}
if (!self.rewardVideoAd.isAdValid) {
self.statusLabel.text = @"广告失效,请重新拉取";
return;
}
[self.rewardVideoAd showAdFromRootViewController:self];
}
func gdt_rewardVideoAdVideoDidLoad(_ rewardedVideoAd: GDTRewardVideoAd!) {
print(@"视频文件加载成功")
}
// 确认激励视频广告有效性之后,在合适的时机展示广告
@IBAction func clickPlay(_ sender: Any) {
if (self.rewardVideoAd.expiredTimestamp <= Int(Date.init().timeIntervalSince1970)) {
self.statusLabel.text = "广告已过期,请重新拉取"
return
}
if (!self.rewardVideoAd.isAdValid) {
self.statusLabel.text = "广告失效,请重新拉取"
return
}
self.rewardVideoAd.show(fromRootViewController: self)
}
在您的ViewController里实现如下回调,处理激励视频广告加载失败的问题:
- (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:(NSError *)error
{
if (error.code == 4014) {
NSLog(@"请拉取到广告后再调用展示接口");
self.statusLabel.text = @"请拉取到广告后再调用展示接口";
} else if (error.code == 4016) {
NSLog(@"应用方向与广告位支持方向不一致");
self.statusLabel.text = @"应用方向与广告位支持方向不一致";
} else if (error.code == 5012) {
NSLog(@"广告已过期");
self.statusLabel.text = @"广告已过期";
} else if (error.code == 4015) {
NSLog(@"广告已经播放过,请重新拉取");
self.statusLabel.text = @"广告已经播放过,请重新拉取";
} else if (error.code == 5002) {
NSLog(@"视频下载失败");
self.statusLabel.text = @"视频下载失败";
} else if (error.code == 5003) {
NSLog(@"视频播放失败");
self.statusLabel.text = @"视频播放失败";
} else if (error.code == 5004) {
NSLog(@"没有合适的广告");
self.statusLabel.text = @"没有合适的广告";
}
NSLog(@"ERROR: %@", error);
}
func gdt_rewardVideoAd(_ rewardedVideoAd: GDTRewardVideoAd!, didFailWithError error: Error!) {
let code = (error as NSError).code
if (code == 4014) {
print("请拉取到广告后再调用展示接口")
self.statusLabel.text = "请拉取到广告后再调用展示接口"
} else if (code == 5012) {
print("广告已过期")
self.statusLabel.text = "广告已过期"
} else if (code == 4015) {
print("广告已经播放过,请重新拉取")
self.statusLabel.text = "广告已经播放过,请重新拉取"
} else if (code == 5002) {
print("视频下载失败")
self.statusLabel.text = "视频下载失败"
} else if (code == 5003) {
print("视频播放失败")
self.statusLabel.text = "视频播放失败"
} else if (code == 5004) {
print("没有合适的广告");
self.statusLabel.text = "没有合适的广告"
}
print("\(error)")
}
说明:
- 建议在释放激励视频广告 GDTRewardVideoAd 对象之前将 GDTRewardVideoAd 对象的 delegate 属性设置为nil.
- 当用户点击广告弹出内置目标页时,请勿释放 GDTRewardVideoAd 实例。
- 广告从拉取成功会提供 expiredTimestamp 属性表示广告的超时时间,展示广告之前请做广告的有效性检查,广告如果失效请提前重新拉取,否则将作无法展示广告。
如果根据正常的注册流程仍然无法在嵌入腾讯广告联盟SDK的app中看到广告,可以在各个广告形式的delegate失败回调方法中输出错误信息。
腾讯广告联盟在打印广告关键信息时会带上[GDTMob::GDTMob]的标记,其他带有GDTMob标记的log与广告信息无关。
| errorCode | 描述 |
|---|---|
| 3001 | 网络错误 |
| 4001 | 初始化错误, 包括广告位为空、AppKey为空、ViewController 为空 |
| 4003 | 广告位错误 |
| 4006 | 广告未曝光 |
| 4007 | 设备不支持 |
| 4008 | 设备方向不支 持 |
| 4009 | 开屏跳过按钮定义非法 |
| 4010 | 开屏bottomView设置非法 |
| 4011 | 请求广告超时 |
| 4013 | 系统不支持,原生视频模板广告只支持 iOS 9 及以上系统 |
| 4014 | 广告数据返回前尝试展示广告, 例如激励视频拉到广告后才可以调用展示接口 |
| 4015 | 广告已经曝光过,不允许二次展示,请重新拉取 |
| 4016 | 应用横竖方向与广告位支持方向不匹配 |
| 5001 | 后台数据错误 |
| 5002 | 视频素材下载错误 |
| 5003 | 视频素材播放错误 |
| 5004 | 没匹配的广告,禁止重试,否则影响流量变现效果 |
| 5005 | 广告请求量或者消耗等超过日限额,请第二天再请求广告 |
| 5006 | 包名校验非法 |
| 5009 | 广告请求量或者消耗等超过小时限额,请一小时后再请求广告 |
| 5010 | 广告样式校验失败,请检查广告位与接口使用是否一致 |
| 5012 | 广告过期,请重新拉取 |
| 6000 | 未知错误,联系腾讯广告联盟商务同事协助排查 |