Aller au contenu principal
Version: 5.x.x

Google Mobile Ads

This guide shows you how to integrate our BlueStack mediation adapter of Google Mobile Ads SDK with your current Android 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 13 or higher
  • Target iOS 13.0 or higher

The custom event must be defined in the Google Ad Manager UI.

1. Create a Yield groups

  • Create an Ad Network screenshot-admanager.google.com-2019.10.02-22_36_16 (1).jpg
  1. Create a Company with Madvertise Ad-Network name
  2. Choose Appsfire network
  3. Allow mediation

2. Add a Yield Group

screenshot-admanager.google.com-2019.10.08-18_32_29.jpg

  1. Choose a name
  2. Choose a format (You must create a Yield Group by format)
  3. Choose at least one size according format
  4. Target a specific placement

3. Add A Yield Partner and Define a custom event

On your Google Ad Manager UI, create a custom event

yield_group.png

  1. Select Madvertise Ad-Network created on Step 1
  2. Choose Custom Event for Integration type
  3. Choose your platform iOS or Android
  4. Set the following Label, class Name and Parameter according your format :
  • Banner : Label= BlueStackCustomEvent, class Name= BlueStackDFPMediationAdapter.BlueStackCustomEvent and Parameter= /YOUR_APP_ID/PLACEMENT_ID_BANNER
  • Interstitial : Label= BlueStackCustomEvent, class Name= BlueStackDFPMediationAdapter.BlueStackCustomEvent and Parameter= /YOUR_APP_ID/PLACEMENT_ID_INTER
  • Native Ad : Label= BlueStackCustomEvent, class Name= BlueStackDFPMediationAdapter.BlueStackCustomEvent and Parameter= /YOUR_APP_ID/PLACEMENT_ID_NATIVEAD
  • Square Ad : Label= BlueStackCustomEvent, class Name= BlueStackDFPMediationAdapter.BlueStackCustomEvent and Parameter= /YOUR_APP_ID/PLACEMENT_ID_SQUARE
  • RewardVideo Ad : Label= BlueStackCustomEvent, class Name= BlueStackDFPMediationAdapter.BlueStackCustomEvent and Parameter= /YOUR_APP_ID/PLACEMENT_ID_REWARD_VIDEO

Integrate Bluestack DFP mediation adapter in your application project

1. Integration

Intergrate BlueStack SDK:

Check Using CocoaPods or Manual Install in order include Bluestack SDK on your application project.

Intergrate BlueStackDFPMediationAdapter SDK:

  • Using Cocoapods
pod 'BlueStackDFPMediationAdapter'
  • Using Swift Package Manager

Go to your project file --> Package Dependencies --> Add(+) --> Search for https://github.com/azerion/BlueStackDFPMediationAdapter

SPM_dfp_integration.png

Import custom event classes in your source file:

  • Objective-C
#import <BlueStackDFPMediationAdapter/BlueStackDFPMediationAdapter.h>
@import GoogleMobileAds;
  • Swift
import BlueStackDFPMediationAdapter
import GoogleMobileAds

2. Initialize your ads

Note: You must initialize BlueStack SDK using your APP_ID before loading ads of any formats.

2.1 Ads formats:

You may now use BlueStack DFP Adapter to show ads the same way it's described in the DFP Documentation.The adapter code and the setup you did on your Google Ad Manager UI will allow BlueStack Ads to deliver ads.

Note: BlueStack v4.3.0 uses Google-Mobile-Ads-SDK v10. See Migrate from v9 to v10

  Objective-C : 

GADBannerView *bannerView;
......................
_bannerView.rootViewController = self;


Swift :
var bannerView: GAMBannerView!
bannerView.rootViewController = self

  Objective-C : 

[BlueStackCustomEvent setViewController:self];


Swift :
BlueStackCustomEvent.setViewController(self)

  • Native Ads: BlueStackCustomEvent :

    Before you can create custom events, you need to integrate the Native ad format into your app.

    PS: In the Native Ad inplementation you must Passed the ViewController to the BlueStackCustomEvent:**

    Init BlueStackCustomEvent :
  Objective-C : 

[BlueStackCustomEvent setViewController:self];


Swift :
BlueStackCustomEvent.setViewController(self)

  • Rewarded video Ads: BlueStackCustomEvent :

    Before you can create custom events, you need to integrate the Rewarded video ad format into your app.

    PS: In the Rewarded video inplementation you must Passed the ViewController to the BlueStackCustomEvent:**

    Init BlueStackCustomEvent :
  Objective-C : 

[BlueStackCustomEvent setViewController:self];


Swift :
BlueStackCustomEvent.setViewController(self)

3. Custom targeting / Keyword

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

    GAMRequest* request = [GAMRequest request];
BlueStackCustomEventMediationExtras *extras = [[BlueStackCustomEventMediationExtras alloc] initWithKeywords:@"target=mngadsdemo;version=4.0.0" customTargetingBlueStack:@{@"age" :@"25"}];
[request registerAdNetworkExtras:extras];

Swift

        let request = GADRequest()
let extras = BlueStackCustomEventMediationExtras(keywords: "target=mngadsdemo;version=4.0.0", customTargetingBlueStack: ["age" :"25"])
request.register(extras)