Rewarded ads allow you to reward users with in-app items for interacting with video ads, playable ads, and surveys.

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

Rewarded Ad
Rewarded Format

Load Ad

To load an reward ad, call the loadAd method on an IKRewardAd 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(
    screen: String,
    callback: IKLoadAdListener?
)
  

Parameters:

  • screenAd: 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 reward ad, call the showAd method on an IKRewardAd 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: IKShowRewardAdListener?
)
  

Parameters:

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

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

  • adListener: The IKShowRewardAdListener interface is designed to handle the events related to the display of reward-based advertisements. It provides callbacks for various stages of ad display, including showing, dismissing, rewarding, failing, and timing out.

    • onAdsShowed(): Called when a reward ad is successfully displayed.

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

    • onAdsRewarded(): Invoked when the user fulfills the criteria for a reward. This method confirms that the reward should be granted.

    • onAdsShowFail(error: IKAdError): Invoked when there is a failure in displaying the ad. Provides details about the failure.

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

Example

Show Ad with Loading Callback

To display an rewarded ad with loading callback, call the showAd method on an IKRewardAd instance, providing the activity context, the ad unit ID, and an IKShowRewardAdListener to handle the ad display events. The IKShowRewardAdListener interface provides callbacks for handling ad display events.The IKLoadingsAdListener interface provides callbacks for managing the ad’s loading state.

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

Parameters:

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

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

  • adListener: The IKShowRewardAdListener interface is designed to handle the events related to the display of reward-based advertisements. It provides callbacks for various stages of ad display, including showing, dismissing, rewarding, failing, and timing out.

    • onAdsShowed(): Called when a reward ad is successfully displayed.

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

    • onAdsRewarded(): Invoked when the user fulfills the criteria for a reward. This method confirms that the reward should be granted.

    • onAdsShowFail(error: IKAdError): Invoked when there is a failure in displaying the ad. Provides details about the failure.

    • onAdsShowTimeout(): Called if the display of the reward ad 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

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

Check Ad Ready

  IKSdkController.isRewardAdReadyAsync()