Google Mobile Ads
This guide shows you how to integrate our BlueStack mediation adapter of Google Mobile Ads SDK with your current iOS app and set up additional request parameters.
Release notes can be found here
Supported ad formats
- Banners
- Interstitials
- Native Ads
- Rewarded Video
Requirements
- Use Xcode 15.1 or higher
- Target iOS 13.0 or higher
Set up Google Ad Manager
The following steps are needed to add us as a Demand partner in Ad Manager. These changes need to be set up in Google Ad Manager.
Add a new Ad Network
First you need to add us as an Ad Network in Google Ad Manager
- Under Admin, go to Companies
- Click the New Company button and select Ad Network
- For the name, you can use BlueStack, but you are free to enter what you want here
- For Ad Network, please select Improve Digital
- Don't forget to enable the Medation toggle
- Other fields can be ignored
- Press Save
Add Yield Groups
Next we need to add some yield groups.
The basic rule is that for each available format you add one yield group (so one for Banner, one for Interstitial, etc.)
If you already have Yield Groups
set up you can skip this step.
- Under Delivery, go to Yield Groups
- Click the New Yield Group button
- Insert any name you wish to use
- Select the correct Ad Format
- Inventory type should be set to Mobile App
- For Banner, select at least one size that best fits
- Please make sure your app's placements are targetted for this Yield Group
Add A Yield Partner and Define a custom event
Now you have to add us as a Yield
partner in the Yield Group
you just created,
or on a yield group you already have set before.
- Open the
Yield Group
you want to add us as a partner - Scroll down on the page and click the Add yield partner button
- As yield partner, choose the company you added in [Add a new Ad Network]
- Select integration type Custom Event
- Select Platform iOS
- Select Status Active
- Default CPM will be provided by your Azerion representative
- For Label, use: BlueStackCustomEvent
- For Class Name, use: BlueStackGoogleMediationAdapter.BlueStackCustomEvent
- As parameter, please enter the placement ID provided by your Azerion representative that matches the format you intend to use this yield group for
- Repeat for each Yield group / format
Set up BlueStack Mediation adapter in Application
SDK Integration
Add BlueStack Core SDK:
Please check the Integration Documentation of the BlueStack Core SDK to add it to your application.
Add BlueStack Google Mediation Adapter:
- CocoaPods
- Swift Package Manager
pod 'BlueStackGoogleMediationAdapter'
Go to your project file --> Package Dependencies --> Add(+) --> Search for https://github.com/azerion/BlueStack-Google-Mediation
Add the BlueStackGoogleMediationAdapter
to your app's target
Import custom event classes in your source file:
- Objective C
- Swift
#import <BlueStackGoogleMediationAdapter/BlueStackGoogleMediationAdapter.h>
@import GoogleMobileAds;
import BlueStackGoogleMediationAdapter
import GoogleMobileAds
Set up Ad Formats
You must initialize BlueStack SDK
using your APP_ID before loading ads of any formats.
You may now use BlueStack Google Adapter to show ads the same way it's described in the Google Ad Manager Documentation. The adapter code and the setup you did on your Google Ad Manager will allow BlueStack Ads to deliver ads.
Banner / Square
Before you can create custom events, you need to integrate the banner ad format into your app.
You must pass the ViewController to the GADBannerView
- Objective C
- Swift
GADBannerView *bannerView;
......................
bannerView.rootViewController = self;
var bannerView: GADBannerView!
bannerView.rootViewController = self
Interstitial
Before you can create custom events, you need to integrate the Interstitial ad format into your app.
In the Interstitial Ad implementation you must pass the ViewController to the BlueStackCustomEvent
- Objective C
- Swift
[BlueStackCustomEvent setViewController:self];
BlueStackCustomEvent.viewController = self
Native Ads
Before you can create custom events, you need to integrate the Native ad format into your app.
In the Native Ad implementation you must pass the ViewController to the BlueStackCustomEvent
- Objective C
- Swift
[BlueStackCustomEvent setViewController:self];
BlueStackCustomEvent.viewController = self
Rewarded video Ads
Before you can create custom events, you need to integrate the Rewarded video ad format into your app.
In the Rewarded video implementation you must pass the ViewController to the BlueStackCustomEvent
- Objective C
- Swift
[BlueStackCustomEvent setViewController:self];
BlueStackCustomEvent.viewController = self
Custom targeting / Keywords
If you need to send your custom key-value pairs. You can specify key-value-targeting and keywords information in the ad request as follows,and you must send your custom key-value pairs also as follows,add the extras to the registerAdNetworkExtras method as follows:
- Objective C
- Swift
GADRequest* request = [GADRequest request];
BlueStackCustomEventMediationExtras *extras = [[BlueStackCustomEventMediationExtras alloc] initWithKeywords:@"target=mngadsdemo;version=5.1.3" customTargetingBlueStack:@{ @"age" :@"25",@"consent" :@"test",@"gender" :@"male"}];
[request registerAdNetworkExtras:extras];
let request = GADRequest()
let keyword = "target=mngadsdemo;version=5.1.3"
let json = ["age" :"25",
"consent" :"test",
"gender" :"male"]
let extras = BlueStackCustomEventMediationExtras(keywords: keyword, customTargetingBlueStack: json)
request.register(extras)