Interstitial ads are full-screen ads that cover the interface of their host app. They’re typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

Here is an example of what a interstitial ad looks like:

Interstitial Ad
Interstitial Format

Load Ad

To load an interstitial ad, call the loadAd method on an IKInterstitialAd instance and provide the ad unit ID along with an IKLoadAdListener to receive the loaded ad or any potential errors. Note that, like other ad format load callbacks, IKLoadAdListener utilizes IKAdError to provide more detailed error information.

  fun loadAd(
    screenAd: String,
    callback: IKLoadAdListener?
)
  

Parameters:

  • screen: considered as a unitId, our team will send you the screenAd list.

  • callback: The IKLoadAdListener interface is designed to manage responses related to the loading of ads. It provides callbacks for handling both the successful loading of ads and the scenarios where ad loading fails.

    • onAdLoaded(): Called when the ad is displayed. This method must be implemented to define the actions to be taken when an ad is shown.
    • onAdLoadFail(error: IKAdError): Invoked when there is a failure in loading the ad. It takes an IKAdError object as a parameter, which contains details about what caused the failure.
Example

Show Ad

Basic Show Function

To display an interstitial ad, call the showAd method on an IKInterstitialAd instance, providing the activity context, the ad unit ID, and an IKShowAdListener to handle the ad display events. The IKShowAdListener interface provides callbacks for handling ad show failures and ad dismissals.

  fun showAd(
    activity: Activity?,
    screen: String,
    adListener: IKShowAdListener?
)
  

Parameters:

  • activity: The Activity in which the interstitial ad will be shown. This can be null if no specific activity context is required.

  • screen: considered as a unitId, our team will send you the screenAd list.

  • adListener: The IKShowAdListener interface

    • onAdsShowed(): Called when an ad is successfully displayed

    • onAdsDismiss(): Triggered when an ad is dismissed by the user. Used for cleanup or handling the next steps

    • onAdsShowFail(error: IKAdError): Invoked when the ad fails to display. Provides details about the failure

    • onAdsShowTimeout(): Called if the ad display times out. Useful for handling scenarios when ad loading exceeds a set time limit

Example

Show Ad with Loading Callback

To display an interstitial ad with loading callback, call the showAd method on an IKInterstitialAd instance, providing the activity context, the ad unit ID, and an IKShowAdListener to handle the ad display events. The IKShowAdListener interface provides callbacks for handling ad show failures and ad dismissals.The IKLoadingsAdListener interface provides callbacks for managing the ad’s loading state.

  fun showAd(
    activity: Activity?,
    screen: String,
    adListener: IKShowAdListener?,
    loadingCallback: IKLoadingsAdListener? = null
)
  

Parameters:

  • activity: The Activity in which the interstitial ad will be shown. This can be null if no specific activity context is required.

  • screen: considered as a unitId, our team will send you the screenAd list.

  • adListener: The IKShowAdListener interface

    • onAdsShowed(): Called when an ad is successfully displayed

    • onAdsDismiss(): Triggered when an ad is dismissed by the user. Used for cleanup or handling the next steps

    • onAdsShowFail(error: IKAdError): Invoked when the ad fails to display. Provides details about the failure

    • onAdsShowTimeout(): Called if the ad display times out. Useful for handling scenarios when ad loading exceeds a set time limit

  • loadingCallback: The IKLoadingsAdListener abstract class is designed for managing the ad display lifecycle events while taking into account the loading time. It encapsulates the behavior of ads in terms of showing and closing, and includes a timing element to track the duration for which an ad was loading.

    • Properties

      • timeLoading: The duration in milliseconds that the ad was loading.
    • Methods

      • onShow(): Called when the ad is displayed. This method must be implemented to define the actions to be taken when an ad is shown.

      • onClose(): Called when the ad display is closed. This method must be implemented to define the actions to be taken when an ad is closed.

Example

Show Ad Upon App Exit

This function stops loading ads after the app is exited, making it crucial for showing an interstitial ad as the user exits the app.

  fun showAdBackApp(
        activity: Activity?,
        adListener: IKShowAdListener?
)
  

Extension with Loading Callback

  fun showAdBackApp(
        activity: Activity?,
        adListener: IKShowAdListener?,
        loadingCallback: IKLoadingsAdListener? = null
)
  

Destroy Ad

In certain scenarios, Ad can be prone to memory leaks. Therefore, it is essential to destroy the ad when your Fragment or Activity is destroyed to manage resources properly.

  fun destroy()
  
Example