# Rewarded Video

Rewarded Video has strong interaction and has become the mainstream of mobile ad industry. It is increasingly becoming the main way for game developers to realize IAA, and more and more super casual game developers select IAA instead of IAP.

The reward of Rewarded Video is generally the gold coin and ability value in the game, which can be obtained when the users watch the full video.We recommend that the Rewarded Video is put in IAP that users have participate in or are seeking rewards, for example, complete a game level or recharge node.

The Rewarded Video of Mind Mediation provides a good reward experience, allowing users to watch the full video to get the virtual currency or reward.This section describes how to integrate with and apply Rewarded Video. Images

# Step 1: Set Up Rewarded Video Callback Listener

SDK will trigger a series of events to inform the app of Rewarded Video activities, such as Rewarded Video inventory status, Rewarded Video playback completion and users' reward. Developers need to know whether the Rewarded Video is ready and users need to be rewarded through events.Therefore, setting and implementing the interface method of Rewarded Video Callback Listener is a necessary operation to use Rewarded Video.The following code snippet demonstrates how to implement the RewardedVideoListener interface to receive and handle Rewarded Video events.

All events triggered by Rewarded Video can be found in the following code.

RewardedVideoAd.setAdListener(new RewardedVideoListener() {

    /**
     * Invoked when the ad availability status is changed.
     *
     * @param - available is a boolean. 
     *  True: means the rewarded videos is available and 
     *           you can show the video by calling RewardedVideoAd.showAd().
     *  False: means no videos are available
     */
    @Override
    public void onRewardedVideoAvailabilityChanged(boolean available) {
        // Change the rewarded video state according to availability in app.
            // You could show ad right after it's was loaded here
    }

    /**
     * Invoked when the RewardedVideo ad view has opened.
     * Your activity will lose focus.
     */
    @Override
    public void onRewardedVideoAdShowed(Scene scene) {
        // Do not perform heavy tasks till the video ad is going to be closed.
    }

    /**
     * Invoked when the RewardedVideo ad is to be closed.
     * Your activity will regain focus.
     */
    @Override
    public void onRewardedVideoAdClosed(Scene scene) {
    // video Ad Closed
    }

    /**
     * Invoked when the user clicked on the RewardedVideo ad.
     */
    @Override
    public void onRewardedVideoAdClicked(Scene scene) {
    // video Ad Clicked
    }

    /** 
     * Invoked when the video is completed and the user should be rewarded. 
     * If using server-to-server callbacks you may ignore this events and wait 
     * for the callback from the MintMediation server. 
     */ 
    @Override
    public void onRewardedVideoAdRewarded(Scene scene) {
        // Here you can reward the user according to your in-app settings.
    }

    /* Invoked when the call to show a rewarded video has failed 
     * @param - error contains the reason for the failure:
     */
    @Override
    public void onRewardedVideoAdShowFailed(Error error) {
       // video Ad show failed
       // 
   }

})

WARNING

Warning: The error parameter in the onRewardedVideoAdShowFailed() callback contains the cause of failure. Please refer to Error Code.

# Step 2: Present Rewarded Video

Ad Availability Check

Mint Mediation SDK will automatically load Rewarded Video for the maintenance of Rewarded Video inventory. You only need to complete the SDK integration and initialization correctly.The app will receive the event notification of change in Rewarded Video availability by implementing the RewardedVideoListener interface, and obtain whether current Rewarded Video is available through the available parameter of onRewardedVideoAvailabilityChanged interface.

public void onRewardedVideoAvailabilityChanged(boolean available)

Of course, you can directly call the isReady() method to check the Rewarded Video inventory status as shown below.

RewardedVideoAd.isReady()

Present Rewarded Video

Once the true callback of onRewardedVideoAvailabilityChanged  event is received, you can call the showAd() method to present Rewarded Video.Of course, we do not propose to do so. The availability events occur only when the availability of Rewarded Video changes. This does not necessarily conform to the Rewarded Video scene designed by the app, and it may cause the frequent or even continuous presentation of Rewarded Video, which will cause trouble for users and affect the app experience.You shall select the presentation time of Rewarded Video according to the scene design of Rewarded Video in the app.

// You can present Rewarded Video immediately when it is available, but we do not propose to do so.
public void onRewardedVideoAvailabilityChanged(boolean available) {
	if(available) {
		RewardedVideoAd.showAd(scene)
   }
}

WARNING

Warning: The Rewarded Video presentation in the onRewardedVideoAvailabilityChanged callback can lead to the unforeseen behavior.In general, you shall not do this except that it is in some specific scenes and the call of showAd method is restricted.

If you just want to present Rewarded Video when needed (Rewarded Video scene designed by app), call the isReady() method to check whether Rewarded Video is available, which is our recommended way:

// You can present Rewarded Video whenever needed.
if (RewardedVideoAd.isReady()) {
  RewardedVideoAd.showAd(scene);
}

WARNING

Warning: When you complete Step 2 successfully, it means that Rewarded Video is presented successfully.If you want to present another Rewarded Video, you just need to repeat Step 2 for presentation. You do not need to call the loadAd method to load Rewarded Video manually.
If you aggregate the AdMob ads, you need to ensure that the isReady and showAd  methods are called in the main thread.

Frequency Capping and Frequency

You can use the frequency capping and frequency control to improve the user experience, which can control the number of Rewarded Video presentations within a specified time frame.The frequency capping and frequency are set in the Rewarded Video placement setting in the foreground, and we provide the scene control based on scene. Warning: To ensure that the Rewarded Video button is not presented to users when the Rewarded Video placement is controlled by the frequency capping, you must previously call the following methods to confirm whether current Rewarded Video placement scene reaches the limit of frequency capping. :::

RewardedVideoAd.isSceneCapped(scene);

# Step 3: Reward Users

After users watch the full Rewarded Video, SDK will trigger the onRewardedVideoAdRewarded  event. So your RewardedVideoListener  will receive this event, and then you can reward users.

Therefore, it is necessary to ensure that the listener is set and the onRewardedVideoAdRewarded  callback method is implemented to handle the user rewards.

Server-side Callback

Mint Mediation SDK supports the server-side callback of Rewarded Video. Developers need to set a private callback address (callback URL as shown in the figure below) and specify the information to verify the Rewarded Video callback sent by Mint Mediation to the callback address. Therefore, Mint Mediation needs to bring this verification information in the callback.The verification information is written by developers calling the setExtId() method of SDK. When the Rewarded Video is generated, SDK contacts the Mint Mediation server to inform this device to get the reward and bring the verification information.After verification by the Mint Mediation server, the reward information and verification information are sent to the developer's server through the callback address.For the user device will not contact the developers' server directly, this method can avoid the false Rewarded Video callback events.

Setting Verification Information ExtId

If your Rewarded Video requires the server-side interaction, you need to call the setExtId method to set the user verification information.This method can set different verification information based on scene to distinguish different scene Rewarded Videos and realize the reward distribution by scene.For the ExtId set will be used to verify the Rewarded Video process, this method must be called before showAd presents Rewarded Video.

RewardedVideoAd.setExtId("scene", "Your Ext Id");

Configuring Rewarded Video Server-side Callback URL

Developers need to set the Rewarded Video server-side callback URL in the advanced settings of Rewarded Video placement as shown in the figure below. Images

Callback URL Format

The callback URL is in a regular expression format. Developers can set a custom variable name, and the variable value is written by ExtId.

http://yourendpoint.com?variable_name_you_define={content}

{content} – Verification information, which is filled in by ExtId set at the SDK client by developers to verify the effectiveness of Rewarded Video.

Finished!

Now, you can present Rewarded Video in your app.

# Up Next

You can aggregate other ad types based on our integration documents or test your integration: