로딩중입니다
adPOPcorn DA : iOS
8/26/2015 4:01:50 PM

adPOPcorn DA

adPOPcorn DA (图片广告,展示广告) 是为开发者带来收益的工具。广告形式包括广告条弹窗全屏广告结束画面广告原生广告

Mediation 功能无中间手续费,为开发者提供最大的收益。

请通过以下链接了解服务详情。

[adPOPcorn DA 服务指南]


注意事项
  1. 集成 adPOPcorn add-on 之前,必须先完成 IGAW 共同集成。[IGAW 共同集成 : iOS]
  2. 为了集成 adPOPcorn,须将 AdPopcornDA.framework 文件包含在 Xcode Project 内。[SDK 安装 : iOS]



广告条

广告条是 DA 广告最基本的广告形式,在应用的下端或上端显示条形的广告。


View 设置

为了显示广告条,请生成和添加 View。参考以下示例在需要显示广告条的 ViewController 中添加。


生成 DABannerView Instance

修改 ViewController.m,import DABannerView.h  DAAdSize.h 生成 DABannerView Instance 变数。

#import <AdPopcornDA/DABannerView.h>
#import <AdPopcornDA/DAAdSize.h>

@interface DABannerViewController () <DABannerViewDelegate> 
{
	DABannerView *_bannerView;
}

@end


实现已生成的 DABannerView Instance。

调用 initWithBAnnerViewSize: origin: appKey: spotKey: viewController: API,生成 Instance 并添加视图。各 Parameter 的说明和示例,请参考如下内容。

  • size : 广告条视图尺寸,参考 DAAdSize.h 使用。
  • origin : 广告条视图的位置,输入 CGPoint 类型。
  • appKey : 发放的 IGAWorks AppKey
  • spotKey : 广告条 SpotKey
  • viewController : 广告条显示的 ViewController
@implementation DABannerViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    _bannerView = [[DABannerView alloc] initWithBannerViewSize:DABannerViewSize320x50 origin:CGPointMake(0.0f, self.view.frame.size.height - [DAAdSize adSize:DABannerViewSize320x50].height) appKey:@"发放的 AppKey" spotKey:@"广告条 SpotKey" viewController:self];

    [self.view addSubview:_bannerView];
    
}


广告条尺寸

adPOPcorn DA 广告条仅支持 iPhone, iPod Touch 的尺寸 (W:320, H:50),使用 DABannerView.h 的 DABannerViewSize320x50 定义的常数即可。


Mediation 转换周期

通过 adRefreshRate API,使用 Mediation 功能时,请设置从各个 Network 接收广告的转换周期。设置在 30秒~120秒之间。

如未设置时,维持基本值 (30秒)。

//adRefreshRate = (NSInteger)seconds
_bannerView.adRefreshRate = 35;


Delegate

对广告条中发送的 Event 提供 Delegate。为了使用 Delegate 请添加 DABannerViewDelegate

在 _bannerView Instance 设置 Delegate 进行实现。

  • DABannerViewDidLoadAd : 广告条加载成功
  • DABannerView: didFailToReceiveAdWithError : 广告条加载失败 (传达的错误代码请参考文件最后部分)
  • DABannerViewWillLeaveApplication : 点击广告条
#import "DABannerViewController.h"

@interface DABannerViewController () <DABannerViewDelegate>

@end

@implementation DABannerViewController

- (void)viewDidLoad
{
	[super viewDidLoad];

	// 设置广告条 Delegate
	_bannerView.delegate = self;
}

// 实现广告条 Delegate
- (void)DABannerViewDidLoadAd:(DABannerView *)bannerView
{
    NSLog(@"BannerAd Loading Success");
}

- (void)DABannerView:(DABannerView *)bannerView didFailToReceiveAdWithError:(DAError *)error
{
    NSLog(@"BannerAd Laoding Failed, ErrorCode : %@", error);
}

- (void)DABannerViewWillLeaveApplication:(DABannerView *)bannerView
{
    NSLog(@"BannerAd Clicked");
}

@end

+ _bannerView : ViewController.h 和 m 文件中生成的 DABannerView Instance



全屏广告

全屏广告是显示在整个画面的广告形式。请参考以下内容集成全屏广告。


Instance 生成

在需要显示的 ViewController.m 中,import DAInterstitialAd.h,表明 Instance 变数。

#import <AdPopcornDA/DAInterstitialAd.h>

@interface DAInterstitialADViewController () <DAInterstitialAdDelegate>
{
    DAInterstitialAd *_interstitialAd;
}
@end


修改 ViewController.m,实现已生成的 Instance。

@implementation DAInterstitialADViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    _interstitialAd = [[DAInterstitialAd alloc] initWithKey:@"发放的 AppKey" spotKey:@"全屏广告 SpotKey" viewController:self];
    
}

+ 发放的 AppKey : 在 IGAWorks 中登录应用时发放的 AppKey

+ 全屏广告 SpotKey : adPOPcorn DA 管理页面中生成的全屏广告 SpotKey


显示广告

调用 presentFromViewController API,显示全屏广告。

[_interstitialAd presentFromViewController:self];

+ _interstitialAd : ViewController.h 和 m 文件中生成的 DAInterstitialAd Instance


Delegate

对全屏广告中发生的 Event 提供 Delegate。使用 Delegate 必须添加 DAInterstitialAdViewDelegate

在 _daInterstitialAd Instance 中设置并实现 Delegate。

  • DAInterstitialAdDidLoad : 全屏广告加载成功
  • DAInterstitialAd: didFailToReceiveAdWithError : 全屏广告加载失败 (传达的错误代码请参考文件最后部分)
  • DAInterstitialAdWillLeaveApplication : 点击全屏广告
#import "DAInterstitialADViewController.h"
@interface DAInterstitialADViewController() <DAInterstitialAdViewDelegate>
@end @implementation DAInterstitialADViewController - (void)viewDidLoad { [super viewDidLoad]; // 设置全屏广告 Delegate _daInterstitialAd.delegate = self; } //实现全屏广告 Delegate -(void)DAInterstitialAdDidLoad:(DAInterstitialAd *)interstitialAd { NSLog(@"InterstitialAd Loading Success"); } -(void)DAInterstitialAd:(DAInterstitialAd *)interstitialAd didFailToReceiveAdWithError:(DAError *)error { NSLog(@"InterstitialAd Laoding Failed, ErrorCode : %@", error); } -(void)DAInterstitialAdWillLeaveApplication:(DAInterstitialAd *)interstitialAd { NSLog(@"InterstitialAd Clicked"); } @end

+ _daInterstitialAd : ViewController.h 和 m 文件中生成的 DAInterstitialAd Instance



弹窗广告

广告不完全覆盖整个画面,可以看见背景画面的广告形式。


Instance 生成

在需要显示的 ViewController.m 中,import DAPopupAd.h,表明 Instance 变数。

#import <AdPopcornDA/DAPopupAd.h>

@interface DAPopupAdViewController() <DAPopupAdDelegate>
{
    DAPopupAd * _daPopupAd;
}
@end


修改 ViewController.m,实现已生成的 Instance。

@implementation DAPopupAdViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    _daPopupAd = [[DAPopupAd alloc]initWithKey:@"发放的 AppKey" spotKey:@"弹窗广告 SpotKey"];
    
}

+ 发放的 AppKey : 在 IGAWorks 中登录应用时发放的 AppKey

+ 弹窗广告 SpotKey : adPOPcorn DA 管理页面中生成的全屏广告 SpotKey


显示广告

调用 presentFromViewController API,显示弹窗广告。

[_daPopupAd presentFromViewController:self];

+ _daPopupAd : ViewController.h 和 m 文件中生成的 DAPopupAd Instance


弹窗尺寸

adPOPcorn DA 弹窗广告支持 iPhone, iPod Touch 的尺寸。

  • Portrait : 240*360 (w*h)
  • Landscape : 320*213 (w*h)


Delegate

对弹窗广告中发生的 Event 提供 Delegate。为了使用 Delegate 请添加 DAPopupAdDelegate

在 _daPopupAd Instance 设置 Delegate 进行实现。

  • DAPopupAdDidLoad : 弹窗广告加载成功
  • DAPopupAd: didFailToReceiveAdWithError : 弹窗广告加载失败 (传达的错误代码请参考文件最后部分)
  • DAPopupAdWillLeaveApplication : 点击弹窗广告
  • willOpenDAPopupAd : 调用弹窗广告打开前
  • didOpenDAPopupAd : 调用弹窗广告打开后
  • willCloseDAPopupAd : 调用弹窗广告关闭前
  • didCloseDAPopupAd : 调用弹窗广告关闭后
#import "DAPopupAdViewController.h"
@interface DAPopupAdViewController() <DAPopupAdDelegate>
@end @implementation DAPopupAdViewController - (void)viewDidLoad { [super viewDidLoad]; // 设置弹窗广告 Delegate _daPopupAd.delegate = self; } //实现弹窗广告 Delegate -(void)DAPopupAdDidLoad:(DAPopupAd *)popupAd { NSLog(@"PopupAd Loading Success"); } -(void)DAPopupAd:(DAPopupAd *)popupAd didFailToReceiveAdWithError:(DAError *)error { NSLog(@"PopupAd Laoding Failed, ErrorCode : %@", error); } -(void)DAPopupAdWillLeaveApplication:(DAPopupAd *)popupAd { NSLog(@"PopupAd Loading Success"); } - (void)willOpenDAPopupAd { NSLog(@"- (void)willOpenDAPopupAd"); } - (void)didOpenDAPopupAd { NSLog(@"- (void)didOpenDAPopupAd"); } - (void)willCloseDAPopupAd { NSLog(@"- (void)willCloseDAPopupAd"); } - (void)didCloseDAPopupAd { NSLog(@"- (void)didCloseDAPopupAd"); } @end

+ _daPopupAd : ViewController.h 和 m 文件中生成的 DAPopupAd Instance



原生广告

原生广告是使用从 adPOPcorn DA 服务器接收的 Json 字符串形式的广告信息,加工成需要的形态后显示广告。


Instance 生成

在需要显示的 ViewController.m 中,import DANativeAd.h,表明 Instance 变数。

#import <AdPopcornDA/DANativeAd.h>

@interface DANativeAdViewController() <DANativeAdDelegate>
{
    DANativeAd * _daNativeAd;
}
@end


修改 ViewController.m 没实现已生成的 Instance。

@implementation DANativeAdViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    _daNativeAd = [[DANativeAd alloc]initWithKey:@"发放的 AppKey" spotKey:@"原生广告 SpotKey"];
}

+ 发放的 AppKey : 在 IGAWorks 中登录时发放的 AppKey

+ 原生广告 SpotKey : adPOPcorn DA 管理页面中生成的原生广告 SpotKey


广告加载

调用 loadAd API,加载原生广告信息。加载的信息通过前面生成的 DANativeAdDelegate 传达。

[_daNativeAd loadAd];

+ _daNativeAd : ViewController.h 和 m 文件中生成的 DANativeAd Instance


Delegate (确认广告信息)

对调用 loadAd API 提供 Delegate。为了使用 Delegate 请添加 DANativeAdDelegate

提供广告信息和关于申请失败的 Event Delegate。

  • DANativeAdDidFinishLoading : 原生广告加载成功,返回原生广告信息。
  • DANativeAd: didFailWithError : 原生广告加载失败 (传达的错误代码请参考文件最后部分)
#import "DANativeAdViewController.h"
@interface DANativeAdViewController() <DANativeAdDelegate>
@end @implementation DANativeAdViewController
- (void)viewDidLoad { [super viewDidLoad]; // 设置原生广告 Delegate _daNativeAd.delegate = self; } //实现原生广告 Delegate -(void)DANativeAdDidFinishLoading:(DANativeAd *)nativeAd { //nativeAd : 原生广告信息 Json 字符串 array //ex) nativeAd.nativeAdvertisingResult.campaignListArray } -(void)DANativeAd:(DANativeAd *)nativeAd didFailWithError:(DAError *)error { NSLog(@"NativeAd Laoding Failed, ErrorCode : %@", error);
} @end

+ _daNativeAd : ViewController.h 和 m 文件中生成的 DANativeAd Instance


跟踪广告曝光

调用 callImpression API,跟踪原生广告的曝光情况。需一起传达 API 和 impressionURL Parameter。

[_daNativeAd callImpressionURL:campaign.impressionURL];

+ _daNativeAd : ViewController.h 和 m 文件中生成的 DANativeAd Instance

+ campaign.impressionURL : 在原生广告信息里包括的 Campaign 的 Impression 测试 URL


跟踪广告点击

调用 click API,跟踪原生广告的点击并 Landing 用户。需一起传达 API 和 redirectURL Parameter。

[_daNativeAd click:campaign.redirectURL];

+ _daNativeAd : ViewController.h 和 m 文件中生成的 DANativeAd Instance

+ campaign.redirectURL : 在原生广告信息里包括的 Campaign 的 Impression 测试 URL



DA 答应错误代码定义

各个广告 Event Listener 传达的错误代码的定义。

代码信息说明
200Exception一般错误
1000Invalid ParameterParameter 错误
9999Unknown Server Error未知的服务器错误
2000Invalid Media KeyAppKey 错误
2030Invalid Spot KeySpotKey 错误
2100Empty Campaign无广告
2200Invalid Third Party Name外部 Network 的广告信息加载失败
3200Native Spot Does Not Initialized原生广告设置初始化出错
5000Server Timeout服务器超时
5001Load Ad Failed无法加载特定 Network 的广告
5002No Ad无法加载所有 Network 的广告



DA Mediation

使用 Mediation 时,请参考以下链接进行。

[adPOPcorn DA : iOS (Mediation)]