Pure In-App Bidding Integration

Table of Contents

Mobile API

The Pure In-App Bidding integration is similar to the integration of regular Ad SDK with Prebid in the role of the Ad Server.

In-App Bidding with Prebid

Prebid supports rendering of these ad formats:

  • Display Banner
  • Display Interstitial
  • Video Interstitial
  • Rewarded Video
  • Outstream Video

They can be integrated using these API categories:

Integration example:

// 1. Create an Ad View
let banner = BannerView(frame: CGRect(origin: .zero, size: adSize),
                        configID: CONFIG_ID,
                        adSize: adSize)
    
banner.delegate = self
    
// 2. Load an Ad
banner.loadAd()

Step 1: Create Ad View

Initialize the BannerAdView with properties:

  • frame - the frame rectangle for the view
  • configID - an ID of the Stored Impression on the Prebid Server
  • size - the size of the ad unit which will be used in the bid request.

Step 2: Load the Ad

Call the method loadAd() which will:

  • make a bid request to the Prebid Server.
  • render the winning bid on display.

Outstream Video

For Banner Video you also need to specify the ad format:

banner.adFormat = .video

Interstitial API

Integration example:

// 1. Create an Interstitial Ad Unit
interstitial = InterstitialRenderingAdUnit(configID: CONFIG_ID,
                                  minSizePercentage: CGSize(width: 30, height: 30))
    
interstitial.delegate = self
    
// 2. Load an Ad
interstitial.loadAd()

// .....

// 3. Show An Ad
if interstitial.isReady {
    interstitial.show(from: self)
}

The way of displaying Video Interstitial is almost the same with two differences:

  • Need to customize the ad format
  • No need to set up minSizePercentage

// 1. Create an Interstitial Ad Unit
let interstitial = InterstitialRenderingAdUnit(configID: CONFIG_ID)
    
interstitial.adFormat = .video
interstitial.delegate = self
    
// 2. Load an Ad
interstitial.loadAd()

// .....

// 3. Show An Ad
if interstitial.isReady {
    interstitial.show(from: self)
}

Step 1: Create an Ad Unit

Initialize the Interstitial Ad Unit with properties:

  • configID - an ID of Stored Impression on the Prebid Server
  • minSizePercentage - specifies the minimum width and height percent an ad may occupy of a device’s real estate.

NOTE: minSizePercentage - plays an important role in a bidding process for display ads. If provided space is not enough demand partners won’t respond with the bids.

Step 2: Load the Ad

Call the method loadAd() which will make a bid request to Prebid server.

Step 3: Show the Ad when it is ready

Wait until the ad will be loaded and present it to the user in any suitable time.

// MARK: InterstitialRenderingAdUnitDelegate
    
func interstitialDidReceiveAd(_ interstitial: InterstitialRenderingAdUnit) {
    // Now the ad is ready for display
}

Rewarded API

Integration example:

// 1. Create an Ad Unit
rewardedAd = RewardedAdUnit(configID: CONFIG_ID)
rewardedAd.delegate = self
    
// 2. Load an Ad
rewardedAd.loadAd()

/// .......

// 3. Display the Ad
if rewardedAd.isReady {
    rewardedAd.show(from: self)
}

Step 1: Create Rewarded Ad Unit

Create the RewardedAdUnit object with parameter:

  • configID - an ID of Stored Impression on the Prebid Server

Step 2: Load the Ad

Call the loadAd() method which will make a bid request to Prebid server.

Step 3: Show the Ad when it is ready

Wait until the ad will be loaded and present it to the user in any suitable time.

// MARK: RewardedAdUnitDelegate
    
func rewardedAdDidReceiveAd(_ rewardedAd: RewardedAdUnit) {
    // Now the ad is ready for display
}