Difference between revisions of "IOS Video 4.1.0"

From AdLocus
Jump to: navigation, search
 
Line 12: Line 12:
 
<syntaxhighlight lang="objc">
 
<syntaxhighlight lang="objc">
 
     ALTargeting *targeting = [ALTargeting new];
 
     ALTargeting *targeting = [ALTargeting new];
 +
 
     self.video = [[ALVideo alloc] initWithViewController:self
 
     self.video = [[ALVideo alloc] initWithViewController:self
                                                    key:@"請填入APP KEY"
 
                                              targeting:targeting
 
 
                                                 delegate:self];
 
                                                 delegate:self];
 +
    self.video.key = @"請填入APP KEY";
 +
    self.video.targeting = targeting; //(選擇性) 請參考 ALTargeting 設定
 
     [video load];
 
     [video load];
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 18:19, 2 June 2016

前言

影音版位將以曝光次數高分潤,是您提高收益的最好單元之一。

實作

  • @interface ViewController : UIViewController <ALVideoDelegate>
  • @property (nonatomic, strong) ALVideo *video;
  • - (void) videoDidReceive:(ALVideo *)video


啟用插頁式版位

在您想啟用影音版位的流程中, 加入下列程式碼

    ALTargeting *targeting = [ALTargeting new];
 
    self.video = [[ALVideo alloc] initWithViewController:self
                                                delegate:self];
    self.video.key = @"請填入APP KEY";
    self.video.targeting = targeting; //(選擇性) 請參考 ALTargeting 設定
    [video load];

並透過監聽結果啟用影音插屏

- (void) videoDidReceive:(ALVideo *)video
{
    NSLog(@"Receive AdLocus Video Ad.");
    [video show];
}

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

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

  • videoDidReceive
  • videoDidEnd
- (void) videoDidReceive:(ALVideo *)video
{
    NSLog(@"Receive AdLocus Video Ad.");
    [video show];
}
 
- (void) videoDidEnd:(ALVideo *)video
{
    NSLog(@"End AdLocus Video Ad.");
}