Delegate Methods

Overview πŸ”—

The Chartboost SDK’s delegate methods allow you to exercise greater control over your integration. For example, you can:

  • Log debug messages when your game attempts to load an interstitial.
  • Prevent ads from showing the first time a user plays your game.
  • Determine whether or not a user has clicked an ad or closed it and react accordingly.
  • Prevent an interstitial page from appearing when and where it would interfere with your game.

You can view the Chartboost Android SDK methods in the documentation in the doc folder included with your Android SDK download. You can see many of these methods in use in the sample project included in the package. SDK configuration methods

View Android configuration methods.

Ad Identifier πŸ”—

Error objects (such as CacheError, ShowError, or ClickError) passed as parameters in delegate method calls may include additional error information. All non-error event objects include an adID property.

This is a string that uniquely identifies a cached ad. It might help when working with Chartboost to identify faulty creatives.

onAdExpired πŸ”—

onAdExpired(event: ExpirationEvent) is an optional callback (it has a default empty implementation) that fires when a previously cached ad expires or is removed from the cache. Implement this method if you want to be notified so you can trigger a new cache request.

The ExpirationEvent carries:

  • ad β€” the Ad object that expired.
  • reason β€” an ExpirationReason enum value explaining why:
Value Description
TTL_EXPIRED The ad’s Time-To-Live elapsed.
SIZE_LIMIT_EVICTION The ad was evicted to make space due to cache size limits (LRU policy).
EXPLICIT_EVICTION The ad was explicitly removed via an evict() call.
CACHE_CLEARED The entire cache was cleared.
UNKNOWN The reason could not be determined.
  • override fun onAdExpired(expirationEvent: ExpirationEvent) {
        // Re-cache the ad if needed
        expirationEvent.ad.cache()
    }
    
  • @Override
    public void onAdExpired(@NonNull ExpirationEvent expirationEvent) {
        // Re-cache the ad if needed
        expirationEvent.getAd().cache();
    }