Advertising

Brid SDK custom ad integration

BridSDK gives you the factory methods to pair the player with ads that you set up in BRID CMS. If you need integration of custom ads this section is all about it.

playAdTagUrl

Ad Tag Url instant play. On method playAd() call, player will instantly play ad with custom url.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
	 //Init player
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>];
}

- (void)playAd {
	[self.player playAdTagUrl:<url: URL>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
      	//Init player
		player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)	
    }
  
 	//Method for trigger custom ad url
 	func playAd() {
 		player.playAdTagUrl(<url: URL>)
 	}

}

playAd

Ad Object instant play. On method playAd() call, player will instantly play ad Object.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
	 //Init player
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>];
}

//Method for trigger custom ad object
- (void)playAd {
  
  //create AdData object
  Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
  NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init];
  [mobileArray addObject:mobile]; 
  NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
  //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
  AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];

  
 [self.player playAd:adData];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
      	//Init player
		player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)	
    }
  
 	//Method for trigger custom ad object
 	func playAd() {
    
   	 	//create AdData object
   	    let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
		var mobileArray = [Mobile]()
   	 	mobileArray.append(mobile!) 
		let adPod = [mobileArray]
    	let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
    
    	player.playAd(ad: adData) 
 	}

}

setAd

Temporary change ad.
On method changeAd() call, player will change configuration for ads on next and previous videos, and it will have no effect on ads for current video.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
	 //Init player
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>];
}

//Method for trigger custom ad object
- (void)changeAd {
  
  //create AdData object
  Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
  NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init]; 
  NSMutableArray<AdData*> *adArray = [[NSMutableArray alloc] init];
  [mobileArray addObject:mobile]; 
  NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
  //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
  AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];
 [adArray addObject:adData];
  
 [self.player setAd:<ad: [AdData]>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
      	//Init player
		player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)	
    }
  
 	//Method for trigger custom ad object
 	func changedAd() {
    
    	//create AdData object
   		 let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
		var mobileArray = [Mobile]() 
		var adArray = [AdData]() 
		mobileArray.append(mobile!) 
		let adPod = [mobileArray]
    
   	 	//For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
		let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
		adArray.append(adData!)
    
 		player.setAd(<ad: [AdData]>)
 	}

}

setAdMacros

Custom set ad macros.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
	 //Init player
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>];
}

- (void)adMacros {
    AdMacros *macros = [[AdMacros alloc] initAdMacrosUserAgent:<NSString> referrerUrl:<NSString> pageUrl:<NSString> appStoreUrl:<NSString>];
  
    [_player setAdMacros:macros];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
      	//Init player
		player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)
    }
  
 	//Method for trigger custom ad url
 	func adMacros() {
		let macros = AdMacros(adMacrosUserAgent: <String>, referrerUrl: <String>, pageUrl: <String>, appStoreUrl: <String>)
 		
		player.setAdMacros(macros)
 	}

}

use VPAID mode

Default value is false. For playing VPAID ads, useVPAIDSupport BOOL set to YES/true.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
	 //Init player
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>];
    [player useVPAIDSupport:YES];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
      	//Init player
		player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)
        player.useVPAIDSupport(true)
    }

📘

When creating AdMacros object, proprety inside of object are _Nullable.