Docy

Banners

Note:

The following is a document of the new and improved version of the MAS Banner API. Please follow this guide if you are integrating MAS in your game for the first time.

If you are an existing customer integrating a new game or updating an existing game, we strongly encourage you to use this guide, but you can access the documentation of the old banner API here.

With MAS 4.4.5+, you can show multiple banners in the same screen. All you need to do is to create different banner Ad Views, select the size and set the alignment.

1. Init Yodo1MasBannerAdView

Yodo1MasBannerAdView *bannerAdView = [[Yodo1MasBannerAdView alloc] init];
[bannerAdView setAdSize:Yodo1MasBannerAdSizeBanner];
// TODO: Add bannerAdView to your view hierarchy.
let bannerAdView = Yodo1MasBannerAdView() bannerAdView.setAdSize(.banner)
// TODO: Add bannerAdView to your view hierarchy.

Note: If your game was live with MAS already, please contact your Customer Success Manager about using banners of another size than 320×50.

Size in dpDescriptionAvailabilityAdSize Constant
320×50BannerPhones and TabletsBanner
320×100Large BannerPhones and TabletsLarge Banner
300×250IAB Medium RectanglePhones and TabletsIAB Medium Rectangle
Full-screen width x
Adaptive height
Adaptive BannerPhones and TabletsAdaptive Banner
Screen width x 32/50/90Smart BannerPhones and TabletsSmart Banner

2. Load an ad

Once the Yodo1MasBannerAdView is in place, the next step is to load an ad. That’s done with the loadAd() method in the Yodo1MasBannerAdView class.

Here’s an example that shows how to load an ad in the viewDidLoad method of an UIViewController:

#import 
#import "Yodo1Mas.h"
#import "Yodo1MasBannerAdView.h"

@interface MainController ()

@property (nonatomic, strong) Yodo1MasBannerAdView *bannerAdView;
@end
@implementation BannerController - (void)viewDidLoad {
[super viewDidLoad];
[[Yodo1Mas sharedInstance] initWithAppKey:@"YourAppKey" successful:^{ }
fail:^(NSError * _Nonnull error) { }];
_bannerAdView = [[Yodo1MasBannerAdView alloc] init];
[_bannerAdView setAdSize:Yodo1MasBannerAdSizeBanner];
[_bannerAdView loadAd]; CGSize size = _bannerAdView.intrinsicContentSize;
_bannerAdView.frame =
CGRectMake((self.view.bounds.size.width - size.width) / 2, self.view.bounds.size.height - size.height, size.width, size.height);
[self.view addSubview:_bannerAdView]; } @end
import UIKit
import Yodo1MasCore
class MainController : UIViewController {
var bannerAdView: Yodo1MasBannerAdView! override func viewDidLoad(){
super.viewDidLoad() Yodo1Mas.sharedInstance().initWithAppKey("YourAppKey") { }
fail: { error in } bannerAdView = Yodo1MasBannerAdView()
bannerAdView.setAdSize(.banner) bannerAdView.loadAd() let size = bannerAdView.intrinsicContentSize bannerAdView.frame =
CGRect(x: (self.view.bounds.width - size.width) / 2, y:
self.view.bounds.height - size.height, width: size.width, height: size.height) self.view.addSubview(bannerAdView) } }

That’s it! Your app is now ready to display banner ads.

3. Ad events

To further customize the behavior of your ad, you can hook onto a number of events in the ad’s lifecycle: loading, opening, closing, and so on. You can listen for these events through the Yodo1MasBannerAdListener class.

#import 
#import "Yodo1Mas.h"
#import "Yodo1MasBannerAdView.h"

@interface MainController ()

@property (nonatomic, strong) Yodo1MasBannerAdView *bannerAdView;
@end
@implementation BannerController - (void)viewDidLoad { [super viewDidLoad];
[[Yodo1Mas sharedInstance] initWithAppKey:@"YourAppKey" successful:^{ }
fail:^(NSError * _Nonnull error) { }];
_bannerAdView = [[Yodo1MasBannerAdView alloc] init]; [_bannerAdView setAdSize:Yodo1MasBannerAdSizeBanner]; [_bannerAdView loadAd];
CGSize size = _bannerAdView.intrinsicContentSize; _bannerAdView.frame =
GRectMake((self.view.bounds.size.width - size.width) / 2,
self.view.bounds.size.height - size.height, size.width, size.height);
[self.view addSubview:_bannerAdView]; }
#pragma mark - Yodo1MasBannerAdViewDelegate - 
(void)onBannerAdLoaded:(Yodo1MasBannerAdView *)banner { } -
(void)onBannerAdFailedToLoad:(Yodo1MasBannerAdView *)banner withError:
(Yodo1MasError *)error { } - (void)onBannerAdOpened:
(Yodo1MasBannerAdView *)banner { } - (void)onBannerAdFailedToOpen:
(Yodo1MasBannerAdView *)banner withError:(Yodo1MasError *)error { } -
(void)onBannerAdClosed:(Yodo1MasBannerAdView *)banner { }
@end
import UIKit
import Yodo1MasCore

class MainController: UIViewController {
var bannerAdView: Yodo1MasBannerAdView! override func viewDidLoad()
{ super.viewDidLoad() Yodo1Mas.sharedInstance().initWithAppKey("YourAppKey") { }
fail: { error in } bannerAdView =
Yodo1MasBannerAdView() bannerAdView.setAdSize(.banner) bannerAdView.adDelegate = 
self bannerAdView.loadAd() let size =
bannerAdView.intrinsicContentSize bannerAdView.frame = 
CGRect(x: (self.view.bounds.width - size.width) / 2,
y: self.view.bounds.height - size.height, width: size.width, height: size.height)
self.view.addSubview(bannerAdView) } }
extension MainController: Yodo1MasBannerAdViewDelegate
{ // MARK: Yodo1MasBannerAdViewDelegate
func onBannerAdLoaded(_ banner: Yodo1MasBannerAdView)
{ } func onBannerAdFailed(toLoad banner: Yodo1MasBannerAdView, withError error:
Yodo1MasError) { } func onBannerAdOpened(_ banner: Yodo1MasBannerAdView) { }
func onBannerAdFailed(toOpen banner:
Yodo1MasBannerAdView, withError error: Yodo1MasError) { }
func onBannerAdClosed(_ banner: Yodo1MasBannerAdView) { } }

CONTENTS