Rewarded video

Rewarded video - user-initiated ads where users can earn in-app rewards in exchange for viewing a video ad.

1. Display rewarded video

To display rewarded video, call the following code in the activity:

Appodeal.show(activity, Appodeal.REWARDED_VIDEO);

SDK can't show ads without a network connection!

Appodeal.show() returns a boolean value indicating whether the show method call was passed to the appropriate SDK. 

2. Check if a rewarded video is loaded

Appodeal.isLoaded(Appodeal.REWARDED_VIDEO);

3. Use rewarded video callbacks

Appodeal.setRewardedVideoCallbacks(new RewardedVideoCallbacks() {
  @Override
  public void onRewardedVideoLoaded(boolean isPrecache) {
    // Called when rewarded video is loaded
  }
  @Override
  public void onRewardedVideoFailedToLoad() {
    // Called when rewarded video failed to load
  }
  @Override
  public void onRewardedVideoShown() {
    // Called when rewarded video is shown
  }
  @Override
  public void onRewardedVideoShowFailed() {
    // Called when rewarded video show failed
  }
  @Override
  public void onRewardedVideoClicked() {
    // Called when rewarded video is clicked
  }
  @Override
  public void onRewardedVideoFinished(double amount, String name) {
    // Called when rewarded video is viewed until the end
  }
  @Override
  public void onRewardedVideoClosed(boolean finished) {
    // Called when rewarded video is closed
  }
  @Override
  public void onRewardedVideoExpired() {
    // Called when rewarded video is expired
  }
});

All callbacks are called on the main thread.

4. Cache rewarded video manually

To disable automatic caching for rewarded videos, use the code below before the SDK initialization:

Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
To cache rewarded video, use:
Appodeal.cache(activity, Appodeal.REWARDED_VIDEO);
Read more on manual caching in our FAQ.

5. S2S rewarded video callbacks

5.1. Server-to-server (S2S) rewarded video callbacks

To secure your app's economy, we offer S2S reward callbacks. To validate each reward, you need to set up a callback URL on your server that will receive the reward information. Appodeal will pass the user data to your callback URL that you will need to validate and adjust the user balance accordingly.

1. Create the reward callback URL on your server that will receive the reward information.

2. Fill the created URL and the encryption key in the app settings in your dashboard.

3. The reward callback will be sent to your URL using GET request with two parameters:

{http://example.com/reward}?data1={data1}&data2={data2}
4. Your URL should decrypt the data and validate it.

5. Check impression_id for uniqueness and store it in your system to prevent the duplicate of transactions.

To set the user ID, use this method before the SDK initialization:

Appodeal.getUserSettings(this).setUserID("User#123")

We offer sample scripts in Go, PHP, Ruby, Java, Node.js, Python 3, and C# to decrypt the data. If you need samples in other languages, please contact our support team and we will provide it to you.

Sample in PHP: reward.php.

Sample in Ruby: reward.rb.

Sample in Java: reward.java.

Sample in Node.js: reward.js. 

Sample in Python 3: reward.py.

Sample in C#: reward.cs.

Sample in Go: reward.go.

5.2. Get reward data for placement

To get the reward data set for a specific placement use the following method before showing the rewarded video:

Appodeal.getRewardParameters(placementName);
This method returns Pair with the reward amount and the currency.

6. Check if the rewarded video was initialized

To check if the rewarded video was initialized, you can use the method:

Appodeal.isInitialized(activity, Appodeal.REWARDED_VIDEO);
Returns true, if the rewarded video was initialized.

7. Check if autocache is enabled for rewarded video

To check if autocache is enabled for rewarded video, you can use the method:

Appodeal.isAutoCacheEnabled(activity, Appodeal.REWARDED_VIDEO);
Returns true, if autocache is enabled for rewarded video.

8. Get predicted eCPM for rewarded video

To get the predicted eCPM from the next block in the caching queue, use the method:

Appodeal.getPredictedEcpm(Appodeal.REWARDED_VIDEO);

This method is reasonable to use if manual caching of ads is enabled.

9. Mute videos if call volume is muted

You can mute the sound in a rewarded video using the method:

Appodeal.muteVideosIfCallsMuted(true);

This method works if the user's device has silent mode or only vibration enabled.