iOS Banner Ad Unit
Our innovative Banner Ad unit instantly transforms any content wall within an app into premium video inventory. Natively integrated into publishers’ content, Banner champions the user experience with viewable and non-intrusive video advertising.
You can tap into Chocolate Exchange, Amazon, AppLovin, and Google AdMob demand.
Integration Steps
• The default banner size is 300×250 points. You can tap into Chocolate, Amazon, AppLovin, and Google AdMob demand.
• You can also set two additional sizes: 320×50 and 728×90 (only valid for tablets). You can tap into Google AdMob and Amazon demand.
Import libraries
@import ChocolatePlatform_SDK_Core;
Declare a ChocolateBannerAd instance with property in your app’s UIViewController
@property(nonatomic,strong) ChocolateBannerAd * bannerAd;
Fetch and show an ad
Note: you must initialize the Chocolate SDK with the API key provided by us, as described above. No ads will be displayed otherwise.
• Initialize ChocolateBannerAd.
• Select the adsize based on Ad type you chose (Please set this parameter only once)
• ChocolateBanner300x250 – Default size. Not setting the size parameter is equivalent to setting this
• ChocolateBanner320x50 – Small banner, will only give Google AdMob, Criteo, and Amazon ads
• ChocolateBanner728x90 – Valid for tablets only, will only give Google AdMob and Amazon ads
• Load ad
• Tell ChocolateBannerAd where to display it in your app’s view hierarchy.
Please contact Vdopia to obtain your App API key. You can contact us at sdk-support@vdopia.com
//Initialize
self.bannerAd = [[ChocolateBannerAd alloc] initWithDelegate:self];
//set size: not necessary if you want 300x250 banners
self.bannerAd.size = ChocolateBanner320x50; //small banner
Implement event listeners in your ChocolateAdDelegate
-(void)onChocolateAdLoaded:(ChocolateAd *)ad;
-(void)onChocolateAdLoadFailed:(ChocolateAd *)ad because:(ChocolateAdNoAdReason)reason;
-(void)onChocolateAdShown:(ChocolateAd *)ad;
-(void)onChocolateAdClosed:(ChocolateAd *)ad;
-(void)onChocolateAdClicked:(ChocolateAd *)ad;
Note: if you are using multiple instances of Chocolate ads (whether of the same ad unit or different ad units), make sure the callback is acting appropriately for the ad involved. The simplest way is to check the ad’s identity:
-(void)onChocolateAdLoaded:(ChocolateAd *)ad {
if(ad == self.bannerAd) {
//the declared banner ad is loaded
} else {
//another ad, process appropriately for that ad
}
}
After receiving the onChocolateAdLoaded:
callback, you can display the ad within your app at a location of your choosing:
[self.bannerAd showIn:self.view at:self.view.center];
The ad will be a subview of the view passed in to the showIn:at:
method, and have its center aligned with the point passed in with respect to that view.
Example Sample Code
@import ChocolatePlatform_SDK_Core;
@interface BannerExampleViewController ()
@property(nonatomic,strong) ChocolateBannerAd *bannerAd;
@end
@implementation InViewExampleViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.bannerAd = [[ChocolateBannerAd alloc] initWithDelegate:self];
self.bannerAd.size = ChocolateBanner320x50; //small banner
[self.bannerAd load];
}
#pragma mark ChocolateAdDelegate Listeners
-(void)onChocolateAdLoaded:(ChocolateAd *)ad {
[self.bannerAd showIn:self.view at:self.view.center];
}
-(void)onChocolateAdLoadFailed:(ChocolateAd *)ad because:(ChocolateAdNoAdReason)reason {
self.bannerAd = nil;
}
-(void)onChocolateAdShown:(ChocolateAd *)ad {}
-(void)onChocolateAdClosed:(ChocolateAd *)ad {}
-(void)onChocolateAdClicked:(ChocolateAd *)ad {}
@end
How to turn on ads on your ad unit
Please send us your sample app with the integrated code. We will help you validate the SDK setup and turn on the demand.