iOS Banner Integration

In order to integrate the Banner ads, you need to use the Yodo1MasBannerAdDelegate delegate.

1. Set up the banner ad delegate method

For Swift

Yodo1Mas.sharedInstance().bannerAdDelegate = self

func onAdOpened(_ event: Yodo1MasAdEvent) {
         
}
    
func onAdClosed(_ event: Yodo1MasAdEvent) {
        
}
    
func onAdError(_ event: Yodo1MasAdEvent, _ error: Yodo1MasError) {

}

For Objective C

[Yodo1Mas sharedInstance].bannerAdDelegate = self;

#pragma mark - Yodo1MasAdDelegate
- (void)onAdOpened:(Yodo1MasAdEvent *)event {
    
}

- (void)onAdClosed:(Yodo1MasAdEvent *)event {
    
}

- (void)onAdError:(Yodo1MasAdEvent *)event error:(Yodo1MasError *)error { }


2. Show banner ad

Use the show method to display a banner.

For Swift

Yodo1Mas.sharedInstance().showBannerAd()

For Objective C

[[Yodo1Mas sharedInstance] showBannerAd];

The default alignment is Bottom/Center, here is how you can make it Top/Center

For Swift

let align = Yodo1MasAdBannerAlignTop
Yodo1Mas.sharedInstance().showBannerAd(with: align)

For Objective C

Yodo1MasAdBannerAlign align = Yodo1MasAdBannerAlignTop | Yodo1MasAdBannerAlignHorizontalCenter;
[[Yodo1Mas sharedInstance] showBannerAdWithAlign:align];

You can  customize the banner alignment and offset.

For Swift

let align = Yodo1MasAdBannerAlignTop
let point = CGPoint(x: 10.0, y: 10.0)
Yodo1Mas.sharedInstance().showBannerAd(with: align, offset: point)

For Objective C

Yodo1MasAdBannerAlign align = Yodo1MasAdBannerAlignTop | Yodo1MasAdBannerAlignHorizontalCenter;
CGPoint point = CGPointMake(10.0f, 10.0f);
[[Yodo1Mas sharedInstance] showBannerAdWithAlign:align offset:point];


4. Dismiss banner ad

For Swift

Yodo1Mas.sharedInstance().dismissBannerAd()

For Objective C

[[Yodo1Mas sharedInstance] dismissBannerAd];
Updated on July 21, 2021

Was this article helpful?

Related Articles