[英]Ionic AdMob Plus - How to track user rewards in a RewardedAd and show the updated balance in the UI?
我正在使用 AdMob-Plus 插件并尝试集成 RewardedAd,如此处所示。
问题:
我想为每个观看的 RewardedAd 提供3 个硬币。 我的主要问题是,在用户观看完整的 RewardedAd 后,我无法弄清楚如何成功跟踪,并通过向其添加新硬币值来增加用户帐户中现有硬币的数量,并将这个新值显示给UI 中的用户。
例子:
如果用户在他的账户中已经有 6 个硬币并且观看了 RewardedAd,那么他的帐户应该将新余额显示为 9 个硬币。 我怎样才能做到这一点?
到目前为止我尝试过的代码:
async loadRewardsAd(): Promise<void> {
this.rewarded = new this.admob.RewardedAd({
adUnitId: this.adRewardedId,
serverSideVerification: {
customData: 'coin=3',
userId: '1234567',
}
});
// Load rewarded
await this.rewarded.load();
// Display rewarded
await this.rewarded.show();
}
据我所知,没有选项可以让总金额显示在广告中,而只有新鲜的奖励积分,如下所示:
if (mRewardedAd != null) {
Activity activityContext = MainActivity.this;
mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
// Handle the reward.
Log.d(TAG, "The user earned the reward.");
int rewardAmount = rewardItem.getAmount();
String rewardType = rewardItem.getType();
}
});
} else {
Log.d(TAG, "The rewarded ad wasn't ready yet.");
}
获取总金额似乎需要登录 AdMob 报告 API,普通观众无法使用该 API: admob/api
cordova-admop api的报告似乎是不可能的,我从来没有找到它的任何功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.