To load a rewarded video ad, you will need to pass an instance of RTBRewardedVideoRequestConfiguration with placementID and the iTunesAppId. Please contact our support for getting the needed IDs.
let configuration =RTBRewardedVideoRequestConfiguration(placementId:<PLACEMENT_ID>, iTunesAppId:"<ITUNES_APP_ID>")configuration.sellerId="<SELLERID>"configuration.bidFloor=<BID_FLOOR>configuration.muteOnStart=truerewardedVideoAd.load(configuration: configuration)
let configuration = RTBRewardedVideoRequestConfiguration(placementId: <PLACEMENT_ID>, iTunesAppId: "<ITUNES_APP_ID>")
configuration.userTargeting = .init(userId: "<USER_ID>", gender: .male, yearOfBirth: 1999, keywords: ["keyword1", "keyword2"])
// yearOfBirth must be a 4-digit number, otherwise, it will be ignored
rewardedVideoAd.show(viewController: self)
import RTBSDK
class ViewController: UIViewController {
let rewardedVideoAd = RTBRewardedVideoAd()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// [Important] Set rewarded video ad delegate to listen to the callbacks
rewardedVideoAd.delegate = self
// Prepare request configurations
let configuration = RTBRewardedVideoRequestConfiguration(placementId: <PLACEMENT_ID>, iTunesAppId: "<ITUNES_APP_ID>")
configuration.sellerId = "<SELLERID>"
configuration.bidFloor = <BID_FLOOR>
configuration.muteOnStart = true
// Request a rewarded video ad using the placement ID and itunes app ID
rewardedVideoAd.load(configuration: configuration)
}
}
extension ViewController: RTBRewardedVideoAdDelegate {
func rewardedVideoAdDidReceiveAd(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, bidInfo: RTBSDK.RTBBidInfo, networkName: String) {
// A rewarded video ad has been loaded
rewardedVideoAd.show(viewController: self)
}
func rewardedVideoAd(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, didFailToReceiveAd errorMessage: String, networkName: String) {
// Failed to load a rewarded video ad
}
func rewardedVideoAdDidRecordClick(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, networkName: String) {
// The rewarded video ad received a click
}
func rewardedVideoAdDidPauseForAd(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, networkName: String) {
// The app paused for displaying a rewarded video ad
}
func rewardedVideoAdDidResumeAfterAd(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, networkName: String) {
// The app resumed after dismissing a rewarded video ad
}
func rewardedVideoAdDidReceiveReward(_ rewardedVideoAd: RTBSDK.RTBRewardedVideoAd, networkName: String) {
// The has earned a reward
}
}