Search code examples
androidadmob

What does a RewardItem contain?


This is the code to present the user with a RewardedAd, an video ad to watch:

        rewardedAd.show(this, new OnUserEarnedRewardListener() {
            @Override
            public void onUserEarnedReward(@NonNull RewardItem rewardItem) {

            }
        });

So if the user earned a reward, there is a RewardItem. This is the documentation for RewardItem, which frankly doesn't document anything. RewardItem offers two methods:

abstract int    getAmount() 

and

abstract String     getType() 

What is the amount actually? The percentage of the video watched maybe? And what are the possible values of type? I have no idea.

The documentation for RewardedAd has a complete code example. So what do they do with the RewardItem? They print it to a Toast:

       rewardedAd.show(
             this,
             new OnUserEarnedRewardListener() {
                 @Override
                 public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                     Toast.makeText(
                         MainActivity.this,
                         "onRewarded! currency: "
                             + rewardItem.getType() + "    amount: "
                             + rewardItem.getAmount(), Toast.LENGTH_SHORT).show();
                 }
             });

So, what is this? Is type an actual currency, like Euros? Is amount the money I just made from the user watching the video?

Is there any authoritive documentation for what a RewardItem actually is?


Solution

  • You can set reward type and amount yourself when you create a rewarded ad unit in your Google AdMob. For example when you set it to type coins and amount 10, that's what you should receive in the callback. Think default is type "" and amount 1.

    See documentation for creating an rewarded ad unit, step 8: https://support.google.com/admob/answer/7311747?hl=en