RewardedVideoAdUnit

Create a new Video Rewarded Ad Unit associated with a Prebid Server configuration ID and a video size.

RewardedVideoAdUnit(configId: String)

Parameters

configId(String): Prebid Server configuration ID.

See AdUnit for additional parameters and methods.


Example

Google Mobile Ads
Import the GoogleMobileAds from google-mobile-sdk.

Swift

//setup PB RewardedVideo
let adUnit = RewardedVideoAdUnit(configId: "1001-1")
//setup AM RewardedVideo
let amRewardedAd = GADRewardedAd(adUnitID: "adUnitId")
//load AM RewardedVideo
let amRequest = GADRequest()
let adUnit.fetchDemand(adObject: amRequest) { (resultCode: ResultCode) in
           amRewardedAd.load(amRequest) { error in
               if let error = error {
                   print("loadAMRewardedVideo failed:\(error)")
               } else {
                   if amRewardedAd?.isReady == true {
                       amRewardedAd?.present(fromRootViewController: self, delegate:self)
                   }
               }
           }
       }

Mopub
Import the Mopub SDK from Mopub.

Swift

//setup PB RewardedVideo
let adUnit = RewardedVideoAdUnit(configId: "1001-1")
//setup MP RewardedVideo
MPRewardedVideo.setDelegate(self, forAdUnitId: "adUnitId")
//load MP RewardedVideo
let targetingDict = NSMutableDictionary()
adUnit.fetchDemand(adObject: targetingDict) { (resultCode: ResultCode) in
           print("Prebid demand fetch for mopub \(resultCode.name())")
           if let targetingDict = targetingDict as? Dictionary<String, String> {
               let keywords = Utils.shared.convertDictToMoPubKeywords(dict: targetingDict)
               MPRewardedVideo.loadAd(withAdUnitID: "adUnitId", keywords: keywords, userDataKeywords: nil, location: nil, mediationSettings: nil)
           }
}