-jio-start-block-type-3
¶ Rewarded Video Ads-jio-style-title ¶ IntroductionRewarded ads are full-screen advertisements that appear between two content pages or during natural breaks in the user's interaction with an application or website. These ads cover the entire screen, providing a highly immersive and attention-grabbing experience. |
![]() |
![]() |
Complete GETTING STARTED section and INITIALIZE SDK section before starting this section.
-jio-end-block-type-3
-jio-start-block-type-2
-jio-style-title
Cache rewarded ads by initializing a JioAdView
, setting up an ad delegate, creating an ad container, adding the ad view, and initiating the caching process with a single call to jioAdView?.cacheAd()
.
jioAdView = JioAdView(adSpotId: "<ADSPOT_KEY_GOES_HERE>", adType: .interstitial, delegate: self, forPresentionClass: self, publisherContainer: adContainer)
jioAdView?.setCustomView(container: CustomContainer) // For custom layout
jioAdView?.cacheAd()
-jio-style-title
When adView.loadAd()
API is called, SDK will try to render the ad inside the container shared.
extension InstreamVC : JIOAdViewProtocol {
func onAdPrepared(adView: JioAdView) {
self.showToast(message: "onAdDataPrepared")
adView.loadAd()
}
}
-jio-style-title
Check for isEligibleForReward
flag inside onAdClosed()
callback
-jio-end-block-type-2
-jio-start-block-type-2
-jio-style-title
This section covers customizing Rewarded ads. Ads can be image or video.
Below API need to be called to enable customization.
jioAdView?.setCustomView(container: customVideoLayout)
Add required elements with their tags to support individual functionality.
Below are the possible values for AdCategory.
• HTML_INTERSTITIAL
• NATIVE_INTERSTITIAL
• VIDEO_INTERSTITIAL
-jio-style-title
class CustomRewardedVideoLayout: UIView {
@IBOutlet weak var contentView: UIView?
@IBOutlet var progressView: UIProgressView?
@IBOutlet var labelTimeIndicator: UILabel?
@IBOutlet var labelAdIndicator: UILabel?
@IBOutlet var btnPlayPause: UIButton?
@IBOutlet var btnClose: UIButton?
@IBOutlet var btnMuteUnMute: UIButton?
@IBOutlet weak var skipLabel: UILabel?
private var totalDuration: Int?
private var overlayAdspots = [String]()
override init(frame: CGRect) {
super.init(frame: frame)
setUpNib()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setUpNib()
}
func setUpNib() {
guard let _ = Bundle(for: type(of: self)).path(forResource: "JiogamesCustomNativeInterstitialVideoLayout", ofType: "nib") else {
SDKLog("Bundle is nil")
return
}
Bundle(for: type(of: self)).loadNibNamed("JiogamesCustomNativeInterstitialVideoLayout", owner: self, options: nil)
guard let contentView = contentView else {
SDKLog("contentView is nil")
return
}
addSubview(contentView)
contentView.frame = self.frame
contentView.tag = VideoAdControlTags.mediaView.rawValue
progressView?.tag = VideoAdControlTags.progressBar.rawValue
progressView?.tintColor = .systemOrange
labelTimeIndicator?.tag = VideoAdControlTags.adcounterLbl.rawValue
labelTimeIndicator?.textColor = .white
btnPlayPause?.tag = VideoAdControlTags.playPauseButton.rawValue
btnPlayPause?.setImage(UIImage(named: "Pause", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .normal)
btnPlayPause?.setImage(UIImage(named: "play", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .selected)
btnMuteUnMute?.tag = VideoAdControlTags.muteUnmuteButton.rawValue
btnMuteUnMute?.setImage(UIImage(named: "UnMute", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .normal)
btnMuteUnMute?.setImage(UIImage(named: "Mute", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .selected)
btnClose?.tag = VideoAdControlTags.closeButton.rawValue
labelAdIndicator?.tag = VideoAdControlTags.adBadge.rawValue
labelAdIndicator?.textColor = .white
skipLabel?.tag = VideoAdControlTags.skipLabel.rawValue
}
}
-jio-style-title
class CustomNativeInterstitialVideoLayout: UIView {
@IBOutlet weak var contentView: UIView?
@IBOutlet var progressView: UIProgressView?
@IBOutlet var labelTimeIndicator: UILabel?
@IBOutlet var labelAdIndicator: UILabel?
@IBOutlet var btnPlayPause: UIButton?
@IBOutlet var btnClose: UIButton?
@IBOutlet var btnMuteUnMute: UIButton?
@IBOutlet weak var skipLabel: UILabel?
private var totalDuration: Int?
private var overlayAdspots = [String]()
override init(frame: CGRect) {
super.init(frame: frame)
setUpNib()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setUpNib()
}
func setUpNib() {
guard let _ = Bundle(for: type(of: self)).path(forResource: "JiogamesCustomNativeInterstitialVideoLayout", ofType: "nib") else {
SDKLog("Bundle is nil")
return
}
Bundle(for: type(of: self)).loadNibNamed("JiogamesCustomNativeInterstitialVideoLayout", owner: self, options: nil)
guard let contentView = contentView else {
SDKLog("contentView is nil")
return
}
addSubview(contentView)
contentView.frame = self.frame
contentView.tag = VideoAdControlTags.mediaView.rawValue
progressView?.tag = VideoAdControlTags.progressBar.rawValue
progressView?.tintColor = .systemOrange
labelTimeIndicator?.tag = VideoAdControlTags.adcounterLbl.rawValue
labelTimeIndicator?.textColor = .white
btnPlayPause?.tag = VideoAdControlTags.playPauseButton.rawValue
btnPlayPause?.setImage(UIImage(named: "Pause", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .normal)
btnPlayPause?.setImage(UIImage(named: "play", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .selected)
btnMuteUnMute?.tag = VideoAdControlTags.muteUnmuteButton.rawValue
btnMuteUnMute?.setImage(UIImage(named: "UnMute", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .normal)
btnMuteUnMute?.setImage(UIImage(named: "Mute", in: Bundle(for: type(of: self)), compatibleWith: nil), for: .selected)
btnClose?.tag = VideoAdControlTags.closeButton.rawValue
labelAdIndicator?.tag = VideoAdControlTags.adBadge.rawValue
labelAdIndicator?.textColor = .white
skipLabel?.tag = VideoAdControlTags.skipLabel.rawValue
}
}
-jio-end-block-type-2