Rewarded
Rewarded is a full-screen ad that provides a reward to the user. To show a rewarded ad, it first needs to be cached. Trying to show an uncached rewarded ad will always fail, so it is recommended to always check if the ad is cached first. You can create and cache as many rewarded ads as you want, but only one can be presented at a time.
A basic implementation would look like this:
fun createAndCacheRewarded() {
this.rewarded = Rewarded("location", callback)
this.rewarded.cache()
}
fun showRewarded() {
if (this.rewarded.isCached()) {
this.rewarded.show()
}
}
// Callback implementation
fun didCacheAd(event: CacheEvent, error: CacheError?) {
if (error != null) {
// Handle error, possibly scheduling a retry
}
}
fun willShowAd(event: ShowEvent) {
// Pause ongoing processes
}
fun didShowAd(event: ShowEvent, error: ShowError?) {
if (error != null) {
// Resume paused processes
}
}
fun didDismissAd(event: DismissEvent) {
// Resume paused processes
}
fun didEarnReward(event: RewardEvent) {
// Update app state with event.reward
}
For more information on integrating and using the Chartboost SDK, please visit our help site documentation at Chartboost Help.
Properties
Functions
Caches an ad. This method will first check if there is a cached ad and, if found, will do nothing. If no cached ad exists, the method will attempt to fetch it from the Chartboost server. Implement didCacheAd(event: CacheEvent, error: CacheError?)
to be notified of the cache request result.
Caches an ad with bid response. This method will parse the provided bid response and cache the ad accordingly.
Clears the ad cache. This will do nothing if there's no cached ad. Otherwise, it will remove any data related to the ad, bringing the ad instance back to a non-cached state. After calling this method, you may call cache
again and a new ad will be fetched.