1. 註冊Vpon
2. 新增應用程式與版位
和 AdMob 不一樣的地方,Vpon 在同一個應用程式內可以規劃不同版位。例如:首頁的banner、列表上的banner,使用者可以藉此觀察哪個版位曝光率比較高。
每個版位都有自己的版位ID,記下來等下程式裡面會用到。
3. 下載SDK
For iPhone最新的版本為 3.2.3
4. 把SDK抓進xcode project
我把資料整理如下,3個資料夾與5個檔案
5. 加入參考 framework
Vpon用到的framework超多的
一般專案基本有4個
加完以後,共21個
6. 編輯要加廣告的 View
sampleViewController.h
Import header file、設定Delegate、宣告變數
...(Skip) #import "VponAdOn.h" #import "AdOnPlatform.h" @interface sampleViewController : UIViewController <VponAdOnDelegate>{
UIScrollView *scroll; }
sampleViewController.m
在 viewDidLoad 去載入廣告,記得換上自己的版位ID
- (void)viewDidLoad
{
#pragma mark VponAdOn
/* Fill Ad ID, allow multiple */
NSArray *arrayLicenseKey = [[NSArray alloc]initWithObjects:
@"YOUR ADVER ID",
nil];
NSArray *arraySubDisplayView = [[VponAdOn sharedInstance] requestAdDelegate:self
licenseKey:arrayLicenseKey
latitude:25.0591342
longtitude:121.5443739
platform:TW
size:ADON_SIZE_320x48];
scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
for (int i = 0; i < [arraySubDisplayView count]; i++) {
UIViewController *display = [arraySubDisplayView objectAtIndex:i];
#pragma mark 1:啟動自動更新廣告 0:關閉
[[NSNotificationCenter defaultCenter] postNotificationName:@"VPON_SET_BANNER_AD" object:display userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"isAutoRefreshAdonAd", nil]];
[display.view setFrame:CGRectMake(0, display.view.frame.size.height * i, display.view.frame.size.width, display.view.frame.size.height)];
[scroll addSubview:display.view];
}
[scroll setBackgroundColor:[UIColor whiteColor]];
[scroll setContentSize:CGSizeMake(320, 48 * [arraySubDisplayView count])];
[self.view addSubview:scroll];
/* Show version */
NSLog(@"Vpon version:%@", [[VponAdOn sharedInstance] versionVpon]);
}
/*
* Following are for debug.
*/
#pragma mark 回傳點擊點廣是否有效
- (void)clickAd:(UIViewController *)bannerView valid:(BOOL)isValid withLicenseKey:(NSString *)adLicenseKey
{
if (isValid == YES) {
NSLog(@"Vpon廣告有效點擊:%@:%@", bannerView, adLicenseKey);
} else {
NSLog(@"Vpon廣告無效點擊 也許已經點擊過了:%@:%@", bannerView, adLicenseKey);
}
}
#pragma mark 回傳Vpon廣告抓取成功
- (void)onRecevieAd:(UIViewController *)bannerView withLicenseKey:(NSString *)licenseKey
{
NSLog(@"Vpon廣告抓取成功:%@:%@", bannerView, licenseKey);
}
#pragma mark 回傳Vpon廣告抓取失敗
- (void)onFailedToRecevieAd:(UIViewController *)bannerView withLicenseKey:(NSString *)licenseKey
{
NSLog(@"Vpon廣告抓取失敗:%@:%@", bannerView, licenseKey);
}
7. 跑模擬器
成功!
補充
使用 xcode 4 但 project 卻是 xcode 3 時期create的,而且deployment target是4.0版以下,可能會遇到下面問題
dyld: lazy symbol binding failed: Symbol not found: _objc_retain Referenced from: ... Expected in: ... dyld: Symbol not found: _objc_retain Referenced from: ... Expected in: ...這個問題是Vpon library跟ARC衝突的關係,按照官網所說,要把特別幾個檔案關閉ARC (加入compile flag: -fno-objc-arc)
但我照做了卻沒有用?!
最後只好用xcode 4重新create new project,然後把 code 全部搬過去才解決這個問題。
參考資料
IPhone Apon SDK 文件 - Vpon官方文件






沒有留言:
張貼留言