iOS Google Ad Manager (GAM) Mediation Adapter supports all display.io Ad Units, except OutsteramVideo.
Google Ad Manager/ display.io ad units mapping:
display.io | GAM | ||
![]() |
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 DIOInterstitialAdapter and in “Parameter” enter the relevant Placement ID.
4b. Banner:
- Add an ad unit;
- Add a custom event: In “Class Name” enter DIOBannerAdapter and in “Parameter” enter the relevant Placement ID.
4c. Medium Rectangle:
- Add an ad unit;
- Add a custom event: In “Class Name” enter DIOMediumRectangleAdapter and in “Parameter” enter the relevant Placement ID.
4d. Infeed:
- Add an ad unit;
- Add custom event: In “Class Name” enter DIOInFeedAdapter and in “Parameter” enter the relevant Placement ID.
4e. Interscroller:
- Add an ad unit;
- Cancel Real-time eCPM for GAM network;
- Add custom event: In “Class Name”enter DIOInterscrollerAdapter 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;
}
@end
6e. Get Interscroller ads from Google Ad Manager 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];
Comments
0 comments
Please sign in to leave a comment.