Admob奖励视频后端身份验证

时间:2018-09-12 08:20:16

标签: android admob rewardedvideoad

我正在尝试了解AdMob如何在视频上工作的逻辑。在我们的应用程序中,我们正在尝试实现一项功能,使用户观看整个视频并获得奖励(在这种情况下,它将是一些宝石)。我是Android应用程序的开发人员,并且已经实现了测试视频,它可以正常工作。现在,这是一个问题:

我们应该如何从后端服务器验证是否已观看并关闭了该视频?可以通过Webhook在后端服务器上执行某些操作吗?因为在Android的“奖励项目”对象中,我们没有与后端部分进行通信的特殊令牌,所以奖励类型为字符串(返回“硬币”),金额为整数。

2 个答案:

答案 0 :(得分:0)

您可以使用RewardedVideoAdListener并选中...

以下是侦听器中的事件/方法-

@Override
public void onRewarded(RewardItem reward) {
    Toast.makeText(this, "onRewarded! currency: " + reward.getType() + "  amount: " + reward.getAmount(), Toast.LENGTH_SHORT).show();
    // Reward the user.
}

@Override
public void onRewardedVideoAdLeftApplication() {
    Toast.makeText(this, "onRewardedVideoAdLeftApplication", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdClosed() {
    Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
    Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdLoaded() {
    Toast.makeText(this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdOpened() {
    Toast.makeText(this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoStarted() {
    Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoCompleted() {
    Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}

答案 1 :(得分:0)

first:实现RewardedVideoAdListener

@Override
public void onRewarded(RewardItem reward) {
    // get reward send to backserver
    // Reward the user.
}

@Override
public void onRewardedVideoAdLeftApplication() {
    // if client cancle the video call
    // send backServer
}

@Override
public void onRewardedVideoAdClosed() {
    Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
    Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdLoaded() {
    Toast.makeText(this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdOpened() {
    Toast.makeText(this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoStarted() {
    Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoCompleted() {
    Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}

使用onRewardedVideoAdLeftApplication()方法