Skip to main content

iOS - Out-stream Video Ad

Overview


Vpon provide Out-stream Video Ad which served outside of a stream video. To optimize ad display performance, Out-stream Video Ad will show as native content and typically without sound to minimize the impact of user experience.

Prerequisites


Before you start to integrate Out-stream Video Ad, please make sure you already finished the items below:

  1. Import Vpon SDK to your Xcode project. If you haven’t done yet, please refer to our Integration Guide to finish your setting.
  2. Contact Vpon PDMKT Team to set up your account and get your License Key.

Start To Implement Out-stream Video Ad


Please follow the steps below to implement Out-stream Video Ad to your application:

  1. Import VpadnSDKAdKit
  2. Declare a VpadnInReadAd instance
  3. Set up VpadnInReadAd object and indicate a License Key
  4. Request for an Out-stream Video Ad
  5. Show Out-stream Video Ad
  6. Set up Delegate Protocol

Please refer to the sample code below to finish your Out-stream Video Ad setting:

@import VpadnSDKAdKit;

@interface VponSdkVastCustomAdViewController () <VpadnInReadAdDelegate>

@property (nonatomic, weak) IBOutlet UIView *videoLoadedView;

// Declare a VpadnInReadAd instance
@property (nonatomic, strong) VpadnInReadAd *VpadnInReadAd;

@end

Set Up VpadnInReadAd Object And Indicate A License Key

- (void) requestVpadnInReadAd {
    // Please replace "License Key" with the one you receive from Vpon PDMKT Team
    _VpadnInReadAd = [[VpadnInReadAd alloc] initWithPlacementId:@"License Key" delegate:self];
    
    // Request Vpon Out-stream Video Ad
    [_VpadnInReadAd loadAdWithTestIdentifiers:@[]];

    // Please use the code snippet below and fill in with your test device's IDFA if you want to request for a test ad
    // [_VpadnInReadAd loadAdWithTestIdentifiers:@[@"your_IDFA"]];
}

Show Custom Out-stream Ad

After receiving ad with videoView(), you can embed the Out-stream Video Ad to the position where you want to display the ad.

#pragma mark - VpadnInReadAd Delegate

- (void) VpadnInReadAdDidLoad:(VpadnInReadAd *)ad {
    UIView *videoView = [ad videoView];
    [_videoLoadedView addSubview:videoView];
    
    videoView.translatesAutoresizingMaskIntoConstraints = NO;
    
    [_videoLoadedView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[videoView]-0-|" options:0 metrics:nil views:@{@"videoView":videoView}]];
    [_videoLoadedView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[videoView]-0-|" options:0 metrics:nil views:@{@"videoView":videoView}]];
}

Interface for Out-stream Video Ad

Vpon provide 3 kinds of interface for Out-stream Video Ad, you can choose the one that match your requirement:

  1. InScrollView
  2. InTableView

Show Out-stream Video Ad in InScrollView


To set up an Out-stream Video Ad in a ScrollView of the application, please follow the steps below:

  1. Import VpadnSDKAdKit
  2. Declare a VpadnInReadAd instance
  3. Set up VpadnInReadAd object and indicate a License Key
  4. Request for an Out-stream Video Ad
  5. Set up Delegate Protocol

Please refer to the sample code below to finish your Out-stream Video Ad setting:

Import VpadnSDKAdKit And Declare VpadnInReadAd

@import VpadnSDKAdKit;

@interface VponSdkVastInScrollViewController () <VpadnInReadAdDelegate>

// Declare a View that will show the ad
@property (nonatomic, weak) IBOutlet UIView *inScrollLoadedView;

// Declare a Constraint to control the height where the ad view start
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *inScrollHeightConstraint;

// Declare a ScrollView for ad display
@property (nonatomic, weak) IBOutlet UIScrollView *inScrollView;

// Declare a VpadnInReadAd instance
@property (nonatomic, strong) VpadnInReadAd *VpadnInReadAd;

@end

Set Up VpadnInReadAd Object And Indicate A License Key

- (void) requestVpadnInReadAd {
    // Please replace "License Key" with the one you receive from Vpon PDMKT Team
    _VpadnInReadAd = [[VpadnInReadAd alloc] initWithPlacementId:@"License Key" placeholder:_inScrollLoadedView heightConstraint:_inScrollHeightConstraint scrollView:_inScrollView delegate:self];
    
    // Request Vpon Out-stream Video Ad
    [_VpadnInReadAd loadAdWithTestIdentifiers:@[]];

    // Please use the code snippet below and fill in with your test device's IDFA if you want to request for a test ad
    // [_VpadnInReadAd loadAdWithTestIdentifiers:@[@"your_IDFA"]];
}

Show Out-stream Video Ad in InTableView


To set up an Out-stream Video Ad in a TableView of the application, please follow the steps below:

  1. Import VpadnSDKAdKit
  2. Declare a VpadnInReadAd instance
  3. Set up VpadnInReadAd object and indicate a License Key
  4. Request for an Out-stream Video Ad
  5. Set up Delegate Protocol

Please refer to the sample code below to finish your Out-stream Video Ad setting:

@import VpadnSDKAdKit;

@interface VponSdkVastInTableViewController () <UITableViewDelegate, UITableViewDataSource, VpadnInReadAdDelegate>

// Declare a TableView for ad display
@property (nonatomic, weak) IBOutlet UITableView *tableView;

// Declare a VpadnInReadAd instance
@property (nonatomic, strong) VpadnInReadAd *VpadnInReadAd;

@end

Set Up VpadnInReadAd Object And Indicate A License Key

- (void) requestVpadnInReadAd {
    // Please replace "License Key" with the one you receive from Vpon PDMKT Team
    // Modify the parameters of insertionIndexPath to decide the position that will embed the ad
    _VpadnInReadAd = [[VpadnInReadAd alloc] initWithPlacementId:@"License Key" insertionIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] tableView:_tableView delegate:self];
    
    // Request Vpon Out-stream Video Ad
    [_VpadnInReadAd loadAdWithTestIdentifiers:@[]];

    // Please use the code snippet below and fill in with your test device's IDFA if you want to request for a test ad
    // [_VpadnInReadAd loadAdWithTestIdentifiers:@[@"your_IDFA"]];
}

Set Up Delegate Protocol


After finishing ad request, implement the delegate protocol as below to listen ad status.

- (void)VpadnInReadAd:(VpadnInReadAd *)ad didFailLoading:(NSError *)error {
	NSLog(@"VpadnInReadAdFailed");	
}

- (void)VpadnInReadAdDidLoad:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidLoad");
}

- (void)VpadnInReadAdDidStart:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidStart");
}

- (void)VpadnInReadAdDidStop:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidStop");
}

- (void)VpadnInReadAdDidMute:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidMute");
}

- (void)VpadnInReadAdDidUnmute:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidUnmute");
}

- (void)VpadnInReadAdWasClicked:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdWasClicked");
}

- (void)VpadnInReadAdDidTakeOverFullScreen:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidTakeOverFullScreen");
}

- (void)VpadnInReadAdDidDismissFullscreen:(VpadnInReadAd *)ad {
	NSLog(@"VpadnInReadAdDidDismissFullscreen");
}

Tips


App Transport Security

Apple recently revised App Transport Security (ATS), to iOS9. Please refer to iOS9 ATS for some modification.

Sample Code

Please refer to our Sample Code for a complete integration sample.

Other Tips

Please refer to the link below to learn more about other ad types: