Interstitial Ads

Interstitials are either static or video ads presented before, during or after the user interacts with your app. The user can view and then immediately dismiss them. This is a non-rewarded format for the user.

circle-info

The speed and stability of a user's internet connections may vary. It is highly recommended to fetch as much in advance of showing an ad as possible. This helps to ensure that all necessary assets are downloaded. For example, you may want to fetch an ad when a level starts or after a previous ad has been shown.

Making the Request

Below is an example of making a request for an Intersitial.

Kotlin
import com.fyber.fairbid.ads.Interstitial

val placementId = "12345"
Interstitial.request(placementId)
Java
import com.fyber.fairbid.ads.Interstitial;

String placementId = "12345";
Interstitial.request(placementId);

Adding Callbacks

The callback code below is required for the SDK to properly track the activity of your ad

Kotlin
Interstitial.setInterstitialListener(object : InterstitialListener {
    override fun onShow(placementId: String, impressionData: ImpressionData) {
        // Called when the interstitial from placement 'placementId' shows up.
        // In case the ad is a video, audio play will start here.
    }

    override fun onClick(placementId: String) {
        // Called when the interstitial from placement 'placementId' is clicked
    }

    override fun onHide(placementId: String) {
        // Called when the interstitial from placement 'placementId' hides.
        // In case the ad is a video, audio play will stop here.
    }

    override fun onShowFailure(placementId: String, impressionData: ImpressionData) {
        // Called when an error arises when showing the interstitial from placement 'placementId'
    }

    override fun onAvailable(placementId: String) {
        // Called when an interstitial from placement 'placementId' becomes available
    }

    override fun onUnavailable(placementId: String) {
        // Called when an interstitial from placement 'placementId' becomes unavailable
    }

    override fun onRequestStart(placementId: String, requestId: String) {
        // Called when an interstitial from placement 'placementId' is going to be requested
        // 'requestId' identifies the request across the whole request/show flow
    }
})

Example Showing an Ad

The following example checks to see if a Placement is available and if it is, uses the show request to display the ad.

Last updated