Separate Loading and Rendering of Banner Ads
Request Ad
let configuration = RTBBannerRequestConfiguration(placementId: <PLACEMENT_ID>, iTunesAppId: <ITUNES_APP_ID>)
configuration.sellerId = "<SELLERID>" // Optional
configuration.bidFloor = <BID_FLOOR> // Optional (in USD)
RTBBannerAdProvider.load(configuration: configuration, size: .banner320x50, userAgent: "<USER_AGENT>", loadDelegate: self)Optional - set user targeting
let configuration = RTBBannerRequestConfiguration(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 ignoredGet Loaded Banner View
func bannerAdDidReceiveAd(bannerBid: RTBSDK.RTBBannerBid) {
DispatchQueue.main.async {
guard let bannerView = RTBBannerAdProvider.getBannerView(bannerBid: bannerBid, delegate: self) else {
return
}
let price = bannerBid.priceCPM // in USD
let bidder = bannerBid.bidder
// Adjust and display the banner view
}
}Complete Code Example
Last updated