Difference between revisions of "IOS InApp"
From AdLocus
| Line 7: | Line 7: | ||
** 宣告 property | ** 宣告 property | ||
** 實作 appkey delegate (- (NSString *)AdLocusAppKey) | ** 實作 appkey delegate (- (NSString *)AdLocusAppKey) | ||
| + | <syntaxhighlight lang="objc"> | ||
| + | |||
| + | </syntaxhighlight> | ||
** 啟動版位 | ** 啟動版位 | ||
| + | <syntaxhighlight lang="objc"> | ||
| + | - (NSString *)AdLocusAppKey | ||
| + | { | ||
| + | return @"請輸入您的APPKEY"; | ||
| + | } | ||
| + | </syntaxhighlight> | ||
=== ViewController.h === | === ViewController.h === | ||
<syntaxhighlight lang="objc"> | <syntaxhighlight lang="objc"> | ||
#import <UIKit/UIKit.h> | #import <UIKit/UIKit.h> | ||
| − | #import "libAdLocus_SDK.h" | + | #import "libAdLocus_SDK.h" //Step 1 |
@interface ViewController : UIViewController <ALBannerViewDelegate> | @interface ViewController : UIViewController <ALBannerViewDelegate> | ||
| − | + | @property (nonatomic, strong) ALBannerView *alBannerView; //Step 2 | |
| − | @property (nonatomic, strong) ALBannerView *alBannerView; | + | |
| − | + | ||
@end | @end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 52: | Line 59: | ||
} | } | ||
| + | |||
| + | </syntaxhighlight> | ||
| + | |||
| + | == 若您需要監聽廣告互動結果 == | ||
| + | 透過實作 ALBannerViewDelegate 監測廣告運行結果 | ||
| + | |||
| + | * adViewDidReceiveAd | ||
| + | * adViewDidFailToReceiveAd | ||
| + | |||
| + | <syntaxhighlight lang="objc"> | ||
- (void)adViewDidReceiveAd:(ALBannerView *)view | - (void)adViewDidReceiveAd:(ALBannerView *)view | ||
{ | { | ||
| Line 61: | Line 78: | ||
NSLog(@"Failed receive AdLocus banner Ad : %@", error); | NSLog(@"Failed receive AdLocus banner Ad : %@", error); | ||
} | } | ||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Revision as of 17:56, 8 October 2014
前言
InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。
設定
- 在您要放入 InApp 的 ViewController
- 匯入 AdLocus 標頭檔 (libAdLocus_SDK.h)
- 宣告 property
- 實作 appkey delegate (- (NSString *)AdLocusAppKey)
- 啟動版位
- (NSString *)AdLocusAppKey { return @"請輸入您的APPKEY"; }
ViewController.h
#import <UIKit/UIKit.h> #import "libAdLocus_SDK.h" //Step 1 @interface ViewController : UIViewController <ALBannerViewDelegate> @property (nonatomic, strong) ALBannerView *alBannerView; //Step 2 @end
ViewController.m
#import "ViewController.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self initAdLocusBannerView]; } - (void)initAdLocusBannerView { self.alBannerView = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; self.alBannerView.delegate = self; [self.alBannerView setBannerAnimationType:AdLocusBannerAnimationTypeRandom]; [self.alBannerView setAutoRefreshWithTime:15]; [self.alBannerView requestAdViewWithDelegate:self]; [self.view addSubview:self.alBannerView]; } // 請回傳AdLocus App Key - (NSString *)AdLocusAppKey { return @"請輸入您的APPKEY"; }
若您需要監聽廣告互動結果
透過實作 ALBannerViewDelegate 監測廣告運行結果
- adViewDidReceiveAd
- adViewDidFailToReceiveAd
- (void)adViewDidReceiveAd:(ALBannerView *)view { NSLog(@"Receive AdLocus banner Ad."); } - (void)adViewDidFailToReceiveAd:(ALBannerView *)view andError:(HyxenAdLocusError *)error { NSLog(@"Failed receive AdLocus banner Ad : %@", error); }