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 DIOAdmobInterstitialAdapter 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 DIOAdmobBannerAdapter 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 DIOAdmobMediumRectangleAdapter 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 DIOAdmobInFeedAdapter 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 DIOAdmobInterscrollerAdapter 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;
}
/*
* For Interscroller, use the following:
*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 15) {
return self.tableView.frame.size.height;
}
return UITableViewAutomaticDimension;
}
@end
6e. Get Interscroller ads from AdMob based on the following:
#import "InterscrollerViewController.h"
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <DIOSDK/DIOController.h>
#import <DIOSDK/DIOInterscrollerView.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:kGADAdSizeFluid];
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];
request.testDevices = @[kGADSimulatorID];
[self.bannerView loadRequest:request];
});
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[DIOController sharedInstance] finishAllAds];
}
- (void)adViewDidReceiveAd:(nonnull GADBannerView *)bannerView{
dioView = self.bannerView.subviews[0].subviews[0].subviews[0].subviews[0];
[dioView removeFromSuperview];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 20) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell1" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (dioView) {
[cell.contentView addSubview:dioView];
[dioView setConstraintForIndexPath:indexPath];
dioView.translatesAutoresizingMaskIntoConstraints = NO;
}
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
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];
Comments
0 comments
Please sign in to leave a comment.