iOS AdMob Mediation Adapter supports all display.io Ad Units.
AdMob/ display.io ad units mapping:
|
display.io |
AdMob |
|
|
Interscroller |
Banner |
 |
 |
Interstitial |
Interstitial |
 |
 |
Infeed |
Banner |
 |
 |
Medium Rectangle |
Banner |
 |
 |
Banner |
Banner |
 |
To set it up:
1. Add the Adapter to your project:
Download source and add required files from “Classes” to your project.
2. Create a Google AdMob account and register an app
3. Use Quick Start guide to setup AdMob SDK
4a. Interstitial: create a mediation group for Interstitial / iOS
- Add an ad unit;
- Cancel Real-time eCPM for Admob network;
- Add custom event: In “Class Name” enter DIOInterstitialAdapter and in “Parameter” enter the relevant Placement ID.
4b. Banner: create a mediation group for Banner / iOS
- Add an ad unit;
- Cancel Real-time eCPM for Admob network;
- Add custom event: In “Class Name” enter DIOBannerAdapter and in “Parameter” enter the relevant Placement ID.
4c. Medium Rectangle: create a mediation group for Banner / iOS
- Add an ad unit;
- Cancel Real-time eCPM for Admob network;
- Add custom event: In “Class Name” enter DIOMediumRectangleAdapter and in “Parameter” enter the relevant Placement ID.
4d. Infeed: create a mediation group for Infeed/ iOS
- Add an ad unit;
- Cancel Real-time eCPM for Admob network;
- Add custom event: In “Class Name” enter DIOInFeedAdapter and in “Parameter” enter the relevant Placement ID.
4e. Interscroller: create a mediation group for Interscroller/ iOS
- Add an ad unit;
- Cancel Real-time eCPM for Admob network;
- Add custom event: In “Class Name”enter DIOInterscrollerAdapter and in “Parameter” enter the relevant Placement ID.
5. Disable the automatic-refresh in AdMob ad unit settings (under advanced settings).
6. Initialize DIO SDK and start AdMob SDK:
[[DIOController sharedInstance] initializeWithProperties:nil appId:@"<YOUR APP ID>" completionHandler:^{
// DIO initialized
[[GADMobileAds sharedInstance] startWithCompletionHandler:^(GADInitializationStatus *_Nonnull status){
// GAD started
}];
} errorHandler:^(NSError *error) {
// Failure
}];
6a. Get Interstitial ads from AdMob based on tutorial.
6b. Get Banner ads from AdMob based on tutorial.
6c. Get Medium Rectangle ads from AdMob based on tutorial
6d. Get Infeed ads from AdMob based on the following:
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <DIOSDK/DIOController.h>
@interface TableViewController () <GADBannerViewDelegate>
@property(nonatomic, strong) GADBannerView *bannerView;
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.translucent = NO;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell1"];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell2"];
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeMediumRectangle];
self.bannerView.delegate = self;
self.bannerView.adUnitID = @"<YOUR_AD_UNIT_ID>";
self.bannerView.rootViewController = self;
dispatch_async(dispatch_get_main_queue(), ^{
GADRequest *request = [GADRequest request];
request.testDevices = @[kGADSimulatorID];
[self.bannerView loadRequest:request];
});
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[DIOController sharedInstance] finishAllAds];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 30;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 15) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell1" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell.contentView.subviews.count > 0) [cell.contentView.subviews[0] removeFromSuperview];
[cell.contentView addSubview:self.bannerView];
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView.leadingAnchor constraintEqualToAnchor:self.bannerView.leadingAnchor].active = YES;
[cell.contentView.trailingAnchor constraintEqualToAnchor:self.bannerView.trailingAnchor].active = YES;
[cell.contentView.topAnchor constraintEqualToAnchor:self.bannerView.topAnchor].active = YES;
[cell.contentView.bottomAnchor constraintEqualToAnchor:self.bannerView.bottomAnchor].active = YES;
return cell;
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = @"Simple Cell";
return cell;
}
/*
* For infeed, use the following:
*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 15) {
CGFloat ratio = 300 / 250.0;
if (CGRectGetHeight(self.tableView.frame) < CGRectGetWidth(self.tableView.frame)) {
return CGRectGetHeight(self.tableView.frame) / ratio;
} else {
return CGRectGetWidth(self.tableView.frame) / ratio;
}
}
return UITableViewAutomaticDimension;
}
@end
6e. Get Interscroller ads from AdMob based on the following:
UITablevView integration:
#import "InterscrollerViewController.h"
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <DIOSDK/DIOController.h>
#import <DIOSDK/DIOInterscrollerView.h>
#import "DIOInterscrollerAdapter.h"
@interface InterscrollerViewController () <GADBannerViewDelegate>
@property(nonatomic, strong) GADBannerView *bannerView;
@end
@implementation InterscrollerViewController
DIOInterscrollerView *dioView;
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.translucent = NO;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell1"];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell2"];
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeMediumRectangle];
self.bannerView.delegate = self;
self.bannerView.adUnitID = @"ca-app-pub-1186601170998955/8184589468";
self.bannerView.rootViewController = self;
dispatch_async(dispatch_get_main_queue(), ^{
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
});
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[DIOController sharedInstance] finishAllAds];
}
- (void)bannerViewDidReceiveAd:(nonnull GADBannerView *)bannerView{
dioView = [DIOInterscrollerAdapter getInterscrollerViewForTableView:bannerView
withInterscrollerSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height)
withBaseSize:kGADAdSizeMediumRectangle];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 39;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row > 0 && indexPath.row % 20 == 0) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell1" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:self.bannerView];
[cell.contentView.leadingAnchor constraintEqualToAnchor:self.bannerView.leadingAnchor].active = YES;
[cell.contentView.trailingAnchor constraintEqualToAnchor:self.bannerView.trailingAnchor].active = YES;
[cell.contentView.topAnchor constraintEqualToAnchor:self.bannerView.topAnchor].active = YES;
[cell.contentView.bottomAnchor constraintEqualToAnchor:self.bannerView.bottomAnchor].active = YES;
return cell;
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = @"Simple Cell";
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
@end
UIScrollView integration:
@implementation InterscrollerScrollViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.translucent = NO;
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeMediumRectangle];
self.bannerView.delegate = self;
self.bannerView.adUnitID = @"ca-app-pub-1186601170998955/8184589468";
self.bannerView.rootViewController = self;
[self.adsView addSubview:self.bannerView];
dispatch_async(dispatch_get_main_queue(), ^{
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
});
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[DIOController sharedInstance] finishAllAds];
}
- (void)bannerViewDidReceiveAd:(nonnull GADBannerView *)bannerView{
self.dioView = [DIOInterscrollerAdapter getInterscrollerViewForScrollView:bannerView
withInterscrollerSize:CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height)
withBaseSize:kGADAdSizeMediumRectangle];
}
- (void)close:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
In order to stop Infeed or Interscroller ads, and release all the resources associated with it (for example when leaving the screen) call:
[[DIOController sharedInstance] finishAllAds];