Android admob无法加载奖励视频但给予奖励

时间:2019-07-06 13:38:22

标签: android admob

我在我的应用程序中集成了admob和admob中介。问题是,当我尝试用伊朗IP加载广告时,admob无法加载视频,并向服务器调用奖励回调!!

当我尝试向其他国家/地区加载ip时,没有问题,如果加载失败,则不会给予奖励。

这是我的代码:

admob配置:

    MobileAds.initialize(activity, "ca-app-pub-*************************");

加载广告:

    RewardedAdCallback showCallback = new RewardedAdCallback() {
        @Override
        public void onRewardedAdClosed() {
            super.onRewardedAdClosed();
        }
        @Override
        public void onUserEarnedReward(@NonNull com.google.android.gms.ads.rewarded.RewardItem rewardItem) {
            super.onUserEarnedReward(rewardItem);
            giveReward();
        }
        @Override
        public void onRewardedAdOpened() {
            super.onRewardedAdOpened();
        }
        @Override
        public void onRewardedAdFailedToShow(int i) {
            super.onRewardedAdFailedToShow(i);
        }
    };
    if (adMobAd == null) {
        adMobAd = new com.google.android.gms.ads.rewarded.RewardedAd(activity,
                activity.getString(R.string.rewarded_ad_unit_id));
          adMobAd = MobileAds.getRewardedVideoAdInstance(activity);
    }
    if (adMobAd.isLoaded()) {
        adMobAd.show(activity, showCallback);
        return;
    }
    ServerSideVerificationOptions options = new ServerSideVerificationOptions.Builder()
            .setCustomData(DeviceUUID.getId()).build();
    adMobAd.setServerSideVerificationOptions(options);
    adMobAd.loadAd(new AdRequest.Builder().build(), new RewardedAdLoadCallback() {
        @Override
        public void onRewardedAdLoaded() {
            super.onRewardedAdLoaded();
            adMobAd.show(activity, showCallback);
        }
        @Override
        public void onRewardedAdFailedToLoad(int i) {
            super.onRewardedAdFailedToLoad(i);
        }
    });

当用户从伊朗请求广告时,将调用onRewardedAdFailedToLoad()回调,并且admob将onUserEarnedReward()回调发送到服务器,而无需在android端对其进行校准。

0 个答案:

没有答案