iOS Google Ad Manager Mediation Adapter supports all display.io Ad Units, except OutsteramVideo.
Google Ad Manager/ 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.
Follow guide to initialize DisplayIO SDK.
2. Create a new Yield Group (Banner) and add Third-Party Yield Partner (DisplayIO) to the Yield Group. If you require more instruction on this please consult the link below: https://support.google.com/admanager/answer/7390828
3. Define a Custom Banner Event using the following guide: https://developers.google.com/ad-manager/mobile-ads-sdk/android/custom-events#banner_custom_event
Update to the following settings:
4a. Interstitial:
- Add an ad unit;
- Add a custom event: In “Class Name” enter DIOAdmobInterstitialAdapter and in “Parameter” enter the relevant Placement ID.
4b. Banner:
- Add an ad unit;
- Add a custom event: In “Class Name” enter DIOAdmobBannerAdapter and in “Parameter” enter the relevant Placement ID.
4c. Medium Rectangle:
- Add an ad unit;
- Add a custom event: In “Class Name” enter DIOAdmobMediumRectangleAdapter and in “Parameter” enter the relevant Placement ID.
4d. Infeed:
- Add an ad unit;
- Add custom event: In “Class Name” enter DIOAdmobInFeedAdapter and in “Parameter” enter the relevant Placement ID.
4e. Interscroller:
- 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.
(Placement ID is available in your account on display.io Publisher Portal)
5. Disable automatic-refresh for banner ad (Google Ad Manager Ad Unit). Make sure DisplayIO mediation group has higher priority (CPM) than others in waterfall.
6. Initialize DIO SDK and Google Mobile Ads SDK:
[[DIOController sharedInstance] initializeWithProperties:properties appId:@"<YOUR APP ID>" completionHandler:^{
// DIO initialized
[[GADMobileAds sharedInstance] startWithCompletionHandler:^(GADInitializationStatus *_Nonnull status){
// GAD started
}];
} errorHandler:^(NSError *error) {
// Failure
}];
6a. Get Interstitial ads from Google Ad Manager based on tutorial.
6b. Get Banner ads from Google Ad Manager based on tutorial.
6c. Get Medium Rectangle ads from Google Ad Manager based on tutorial
6d. Get Infeed ads from Google Ad Manager 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 Google Ad Manager 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.