Difference between revisions of "IOS InApp 4.1.0"

From AdLocus
Jump to: navigation, search
Line 9: Line 9:
 
     self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
 
     self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
 
     self.banner.key = @"請填入您的APP KEY";
 
     self.banner.key = @"請填入您的APP KEY";
     self.banner.targeting = targeting; //請參考 ALTargeting 設定
+
     self.banner.targeting = targeting; //(選擇性) 請參考 ALTargeting 設定
 
     [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
 
     [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
 
     [self.banner setAutoRefreshWithTime:15];
 
     [self.banner setAutoRefreshWithTime:15];
Line 65: Line 65:
 
}
 
}
  
- (void)adViewDidFailToReceiveAd:(ALBannerView *)view andError:(HyxenAdLocusError *)error
+
- (void)adViewDidFailToReceiveAd:(ALBannerView *)view error:(AdLocusError *)error
 
{
 
{
 
     NSLog(@"Failed receive AdLocus banner Ad : %@", error);
 
     NSLog(@"Failed receive AdLocus banner Ad : %@", error);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 18:15, 2 June 2016

前言

InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。

實作

  • #import <AdLocus/AdLocus.h>

啟動版位

    self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    self.banner.key = @"請填入您的APP KEY";
    self.banner.targeting = targeting; //(選擇性) 請參考 ALTargeting 設定
    [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
    [self.banner setAutoRefreshWithTime:15];
    [self.banner requestAdViewWithDelegate:self];
    [self.view addSubview:self.banner];
  • 設定監聽

範例: ViewController.h

#import <UIKit/UIKit.h>
#import <AdLocus/AdLocus.h>
 
@interface ViewController : UIViewController <ALBannerViewDelegate>
@property (nonatomic, strong) ALBannerView *banner;
@end

範例: ViewController.m

#import "ViewController.h"
 
@implementation ViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initAdLocusBannerView];
}
 
- (void)initAdLocusBannerView
{
    self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
    [self.banner setAutoRefreshWithTime:15];
    [self.banner requestAdViewWithDelegate:self];
 
    [self.view addSubview:self.banner];
}

若您需要監聽廣告互動結果

透過實作 ALBannerViewDelegate 監測廣告運行結果

  • adViewDidReceiveAd
  • adViewDidFailToReceiveAd
- (void)adViewDidReceiveAd:(ALBannerView *)view
{
    NSLog(@"Receive AdLocus banner Ad.");
}
 
- (void)adViewDidFailToReceiveAd:(ALBannerView *)view error:(AdLocusError *)error
{
    NSLog(@"Failed receive AdLocus banner Ad : %@", error);
}