简体   繁体   中英

Admob rewarded ad not showed even if the petitions get responses

I have an Android application written in Java where I give coins to use the application by watching a rewardered ad using the Admob advertising.network.

I have followed the new API implementation guide . My frown starts when I receive implementation instructions by email, and they link to the old API . Which of the two APIs do I have to implement?

On the other hand, I start the mediation, and upload an update with a button to see the rewarded ad and get the coins, and another to get free coins. Only the Chocolate.network has accepted me, the rest rejected.

It has been published like this for a week, and every day, my first 500 users click 10 or 20 times and in Admob I get that I receive those requests and that the response rate is 100%, and only 1 or 2 ads are printed. I had to remove the ad because the app could not be used without coins.

On the other hand, I receive a rejection from a mediation in which they ask me about my traffic and they tell me that they will not be able to offer me the service because it would not generate enough ad traffic.

Have I understood correctly? Does that mean that since I only have one app with only 500 users, I can't trade with Admob with rewardered ads? Would the same thing happen to me on Facebook? My intersticial and banner ads work correctly while the rewarded no.

My implementation code in case I have programmed something wrong is the following. With the test id it works, not always on the first click but on the second (sometimes mRewardedAd = null ).

build.graddle (module)

dependencies {
    implementation 'com.google.android.gms:play-services-ads:20.5.0'
}

AndroidManifest.xml

<application>
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-my-app-id"/>
</application>

MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
    });
}

Shop.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    AdRequest adRequest = new AdRequest.Builder().build();
    RewardedAd.load(this, "ca-app-pub-my-rewarded-ad-id",
            adRequest, new RewardedAdLoadCallback() {
                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    // Handle the error.
                    mRewardedAd = null;
                }
                @Override
                public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
                    mRewardedAd = rewardedAd;
                    mRewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                        @Override
                        public void onAdShowedFullScreenContent() {
                            // Called when ad is shown.
                        }

                        @Override
                        public void onAdFailedToShowFullScreenContent(AdError adError) {
                            // Called when ad fails to show.
                        }

                        @Override
                        public void onAdDismissedFullScreenContent() {
                            // Called when ad is dismissed.
                            // Set the ad reference to null so you don't show the ad a second time.
                            mRewardedAd = null;
                        }
                    });
                }
            });
    Button btnAdd = findViewById(R.id.btnAdd);
    btnAdd.setOnClickListener(v -> {
        if (mRewardedAd != null) {
            Activity activityContext = Shop.this;
            mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {
                @Override
                public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                    daCoinsAdd();
                }
            });
        } else {
            switch (languaje) {
                case "es": {
                    Toast toast = Toast.makeText(getApplicationContext(), "No cargó el anuncio.", Toast.LENGTH_SHORT);
                    toast.show();
                    break;
                }
                case "it": {
                    Toast toast = Toast.makeText(getApplicationContext(), "Non ha caricato l'annuncio.", Toast.LENGTH_SHORT);
                    toast.show();
                    break;
                }
                case "fr": {
                    Toast toast = Toast.makeText(getApplicationContext(), "Il n'a pas chargé l'annonce.", Toast.LENGTH_SHORT);
                    toast.show();
                    break;
                }
                default: {
                    Toast toast = Toast.makeText(getApplicationContext(), "It did not load the ad.", Toast.LENGTH_SHORT);
                    toast.show();
                    break;
                }
            }
        }
    });
}    

It is normal that the ad doesn't load in the first click as my app is new and I have no traffic, or I have done something wrongly?

To make sure that your implementation is right and is working use setTestDeviceIds() function that will successfully loads a test ad for you every time, no matter if it is a reward ad or a simple banner add. this is the code:

MobileAds.initialize(this, new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {
        }
    });

    String myTestID = "6A0C784094CAEC07E49258843B0FC530";
    if(App.TestMode) {
        List<String> testDeviceIds = Arrays.asList(myTestID);
        RequestConfiguration configuration = new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
        MobileAds.setRequestConfiguration(configuration);
    }

Ofcourse you should replace your test id, to find your test id:

1- Load your ads-integrated app and make an ad request.

2- Check the logcat output for a message that looks like the one below, which shows you your device ID and how to add it as a test device:

LogCat output will be sothing like this:

I/Ads: Use RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231")) to get test ads on this device."

Copy your test device ID to your clipboard.

For more information visit this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM