This how-to guide covers the ‘Prebid-Rendered’ approach for integrating the Prebid SDK into your app with the Google Next-Gen Mobile Ads SDK. It utilizes:
If you do not have the Next-Gen Mobile Ads SDK in the app yet, refer to the Google Integration Documentation.
Another way to integrate Next-Gen SDK into your app is with the Next-Gen SDK Bidding-Only integration.
Tradeoffs between these integration approaches:
| Aspect | Bidding-Only Integration | Prebid-Rendered Integration |
|---|---|---|
| App code has direct access to bids | ||
| Support for MRAID 3.0 | ||
| Support for SKAdnetwork | ||
| Loads data from Prebid Cache | ||
| Triggers billing and Notice URLs | ||
| Supports Third Party Rendering libraries |
Notes:
The Next-Gen SDK Prebid-Rendered Integration method assumes that you have the following components:
Here’s how the ad bidding-auction-rendering process works in this integration scenario.

Assuming your app already has AdUnits integrated with the Next-Gen Mobile Ads SDK, the technical implementation of Prebid mobile into your app will involve these major steps:
The AdOps team will need to create line items in GAM. The creatives used depend on which media formats your adunits utilize:
| AdUnit Format | Line Item Targeting | Creative Type | Prebid Cache? | Ad Ops Details |
|---|---|---|---|---|
| HTML banner, interstitial banner or video, non-instream video | hb_pb hb_format=banner |
3rd party HTML that loads google_mobile_app_ads.js | no | link |
| Rewarded Video | hb_pb hb_format=video inventoryType in (instream, mobile app) rewarded adunits |
VastUrl pointing to prebid-mobile-rewarded-vast.xml | no | link |
| In-app native | hb_pb hb_format=native |
GAM native | no | link |
Notes:
This information may be useful when comparing data across various reporting systems:
| Scenario | 3pHTML Creative | VastUrl Creative | GAM Native Creative |
|---|---|---|---|
| Rendering Method | js in iframe fires an event | Next-Gen SDK player | App code with data from PBSDK |
| Fires Prebid win event | always | never | always |
| Fires Prebid imp event | always | VAST impression tag | never |
| Fires OpenRTB burl | always (1) | n/a | never |
| Fires OpenRTB nurl | always (1) | n/a | never |
| Fires OpenMeasurement events | PBSDK | n/a | PBSDK |
Notes:
burl and nurl are utilized in a PrebidMobile SDK v3.0.0.First, a little bit of setup is needed.
The Prebid SDK supplies a set of classes called the ‘Next-Gen Event Handlers’ that wrap the Next-Gen Ad Views and manage them in the In-App Bidding flow. These classes are provided in the form of a library that can be added to the app via Gradle:
Root build.gradle:
allprojects {
repositories {
...
mavenCentral()
...
}
}
App module build.gradle:
implementation('org.prebid:prebid-mobile-sdk-next-gen-event-handlers:x.x.x')
Initialize the Next-Gen SDK early in your app lifecycle (e.g., in Application.onCreate()):
val backgroundScope = CoroutineScope(Dispatchers.IO)
backgroundScope.launch {
MobileAds.initialize(
context,
InitializationConfig.Builder("YOUR_APP_ID").build()
) {
// Initialization complete
}
}
This section covers integration details for different ad formats. In each scenario, you’ll be asked for a configId - this is a key worked out with your Prebid Server provider. It’s used at runtime to pull in the bidders and parameters specific to this adunit. Depending on your Prebid Server partner, it may be a UUID or constructed out of parts like an account number and adunit name.
To integrate the banner ad you need to implement three easy steps:
// 1. Create a banner custom event handler for the Next-Gen SDK.
val eventHandler = NextGenBannerEventHandler(requireContext(), NEXT_GEN_AD_UNIT_ID, AdSize(WIDTH, HEIGHT))
// 2. Create a bannerView instance and provide the Next-Gen event handler
bannerView = BannerView(requireContext(), configId, eventHandler)
// (Optional) set an event listener
bannerView?.setBannerListener(this)
// Add bannerView to your viewContainer
viewContainer?.addView(bannerView)
// 3. Execute the loadAd function.
bannerView?.loadAd()
loadAd() should be called on the main thread.
Prebid SDK’s Next-Gen event handlers are special containers that wrap Next-Gen Ad Views and help to manage collaboration between the Next-Gen SDK and Prebid views.
Important: you should create and use a unique event handler for each ad view.
To create the event handler you should provide a Next-Gen Ad Unit Id and one or more AdSize instances for this ad unit.
BannerView - is the view that will display a particular ad. It should be added to the UI. To create it you should provide:
Also, you should add the instance of BannerView to the UI.
And assign the listeners for processing ad events.
Call the loadAd() method to make a bid request.
For Non-Instream Video you also need to specify the video placement type of the expected ad:
bannerView.videoPlacementType = PlacementType.IN_BANNER // or any other available type
Next-Gen SDK setup:
Integration:
AdView with BannerView in the UI.BannerViewListener.AdView and BannerAdRequest.BannerAdUnit.To integrate an interstitial ad follow these steps:
// 1. Create an interstitial custom event handler for the Next-Gen SDK.
val eventHandler = NextGenInterstitialEventHandler(requireContext(), nextGenAdUnitId)
// 2. Create an interstitialAdUnit instance and provide the Next-Gen event handler
interstitialAdUnit = InterstitialAdUnit(requireContext(), configId, eventHandler)
// (Optional) for multiformat, specify the ad unit formats
// interstitialAdUnit = InterstitialAdUnit(requireContext(), configId, EnumSet.of(AdUnitFormat.BANNER, AdUnitFormat.VIDEO), eventHandler)
// (Optional) set an event listener
interstitialAdUnit?.setInterstitialAdUnitListener(this)
// 3. Execute the loadAd function.
interstitialAdUnit?.loadAd()
//....
// 4. After the ad is loaded you can execute the `show` function to trigger ad display
interstitialAdUnit?.show()
loadAd() should be called on the main thread.
In order to make a multiformat bid request, set the respective values into the adUnitFormats parameter:
interstitialAdUnit = InterstitialAdUnit(
requireContext(),
configId,
EnumSet.of(AdUnitFormat.BANNER, AdUnitFormat.VIDEO),
eventHandler)
Next-Gen’s event handlers are special containers that wrap the Next-Gen Ad Views and help to manage collaboration between the Next-Gen SDK and Prebid views.
Important: you should create and use a unique event handler for each ad view.
To create an event handler you should provide a Next-Gen Ad Unit ID.
InterstitialAdUnit - is an object that will load and display a particular ad. To create it you should provide:
Also, you can assign the listeners for processing ad events.
NOTE: minSizePercentage - plays an important role in a bidding process for display ads. If the provided space is too small demand partners won’t respond with bids.
Call the loadAd() method to make a bid request. The ad unit will load an ad and will wait for explicit instructions to display the Interstitial Ad.
The most convenient way to determine if the interstitial ad is ready for displaying is to listen to the listener method:
override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit) {
//Ad is ready for display
interstitialAdUnit.show()
}
Next-Gen SDK setup:
Integration:
InterstitialAd with InterstitialAdUnit.InterstitialAdUnitListener.InterstitialAd and AdRequest.The Rewarded Ad Unit assumes special behavior that should be configurable by the platform or publisher according to the application or ad experience guides.
Configuration of rewarded ad unit can be done by defining the Prebid Server passthrough extension or by using a stored impression-level request on the server.
Prebid SDK will search for a particular rwdd object in $.seatbid.bid.ext.prebid.passthrough of bid response to configure the behavior and rendering of the Rewarded Ad Unit. The following table describes the structure and usage purpose of rwdd configuration parameters.
| Attribute | Type | Description | Example |
|---|---|---|---|
reward |
object (optional) |
Metadata provided by the publisher to describe the reward. | { |
reward.type |
string | Type of the reward in the app’s coins. | "SuperDollars" |
reward.count |
integer | Amount of coins. | 10 |
reward.ext |
object | For future extensions. | { |
completion |
object (optional) |
Describes the condition when the SDK should send a signal to the app that the user has earned the reward. | { |
completion.banner |
object | Details for banner ad completion. | { |
completion.banner.time |
integer | Period of time the banner ad is on screen. | 5 |
completion.banner.event |
string | URL with custom schema sent by the creative to indicate that the user did earn a reward. | "rwdd://userDidEarnReward" |
completion.video |
object | Details for video ad completion. | { |
completion.video.time |
integer | Period of time the video ad is on screen. | 10 |
completion.video.playbackevent |
string | The playback event stage in the video. | "start", "firstquartile", "midpoint", "thirdquartile", "complete" |
completion.video.endcard |
object | Properties for the end card. | { |
completion.video.endcard.time |
integer | Period of time the end card is on screen. | 5 |
completion.video.endcard.event |
string | URL with custom schema sent by the creative for end card. | "rwdd://userDidEarnReward" |
close |
object (optional) |
Describes the ad close behavior after the reward is earned. | { |
close.postrewardtime |
integer | Time interval (seconds) after reward event when SDK should close interstitial. | 3 |
close.action |
string | Action SDK should make: "autoclose" (close interstitial) or "closebutton" (show close button) |
"autoclose" |
An example of an impression-level stored request:
{
"video": {
"h": 480,
"w": 320,
"mimes": ["video/mp4"],
"linearity": 1,
"placement": 2,
"playbackmethod": [2]
},
"ext": {
"prebid": {
"passthrough": [
{
"type": "prebidmobilesdk",
"rwdd": {
"reward": {
"type": "SuperDollars",
"count": 10
},
"completion": {
"video": {
"endcard": {
"time": 5
}
}
},
"close": {
"postrewardtime": 3,
"action": "autoclose"
}
}
}
]
}
}
}
More details about the SDK behavior according to the rwdd configuration you can find in the GitHub Proposal.
Displaying the Rewarded Ad is the same as displaying an Interstitial Ad, but it adds the ability to handle a reward. To display a Rewarded Ad follow these steps:
// 1. Create a rewarded custom event handler for the Next-Gen SDK.
val eventHandler = NextGenRewardedEventHandler(requireActivity(), nextGenAdUnitId)
// 2. Create a rewardedAdUnit instance and provide the Next-Gen event handler
rewardedAdUnit = RewardedAdUnit(requireContext(), configId, eventHandler)
// You can also set an event listener, this step is optional.
rewardedAdUnit?.setRewardedAdUnitListener(this)
// 3. Execute the loadAd function.
rewardedAdUnit?.loadAd()
//...
// 4. After the ad is loaded you can execute the `show` function to display the ad.
rewardedAdUnit?.show()
loadAd() should be called on the main thread.
Next-Gen’s event handlers are special containers that wrap the Next-Gen Ad Views and help to manage collaboration between the Next-Gen SDK and Prebid views.
Important: you should create and use a unique event handler for each ad view.
To create an event handler you should provide a Next-Gen Ad Unit ID.
RewardedAdUnit - is an object that will load and display the particular ad. To create it you should provide:
You can also assign the listener for processing ad events.
Call the loadAd() method to make a bid request. The ad unit will load an ad and will wait for explicit instructions to display the Rewarded Ad.
The most convenient way to determine if the ad is ready for displaying is to listen for the listener method:
override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit) {
//Ad is ready for display
rewardedAdUnit.show()
}
Handle earning the reward in the appropriate method. Important: a reward can be null.
override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) {
if (reward != null) {
val rewardType = reward.type
val rewardCount = reward.count
val rewardExt = reward.ext
// Process the reward
}
}
Next-Gen SDK setup:
Integration:
RewardedAd with RewardedAdUnit.RewardedAdUnitListener.RewardedVideoAdUnit.The adPosition property allows developers to specify the position of the ad within the publisher’s content. This property maps to the pos field in the OpenRTB specification under the imp[].banner or imp[].video objects, depending on the ad format. The possible values for this field could be found in the respective specification.
You can set adPosition by using the following method:
adUnit.setAdPosition(AdPosition.FOOTER);