diff --git a/README.md b/README.md index 447d93cf..62c05ac6 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,24 @@ While the Ionic community have provided [an Ionic Native Plugin](https://ionicfr As I ([@ratson](https://github.com/ratson)) don't use Ionic myself, it would be great if some experienced Ionic developers could help answering questions or come up with more examples. HELP WANTED HERE. +## FAQ + +### My video rewards are not working on test mode (Android). + +You need to set your tests devices array. [AdMob official](https://developers.google.com/admob/android/test-ads#enable_test_devices) says: + +In LogCat search for: +``` +I/Ads: Use AdRequest.Builder.addTestDevice("33BE2250B43518CCDA7DE426D04EE231") +to get test ads on this device." +``` +`33BE2250B43518CCDA7DE426D04EE231` is your device id send it with your video reward config in this way: +``` +config = { + testDevices: ['33BE2250B43518CCDA7DE426D04EE231'] +} +``` + ## Credits Thanks for the [cordova-plugin-admob-simple](https://github.com/sunnycupertino/cordova-plugin-admob-simple) author for forking the original project [cordova-plugin-admob](https://github.com/floatinghotpot/cordova-plugin-admob) to [make it functional](https://github.com/sunnycupertino/cordova-plugin-admob-simple/issues/1) and open source it. diff --git a/package.json b/package.json index 48a87cee..5f93f87e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-admob-free", - "version": "0.27.0", + "version": "0.27.1", "description": "Cordova AdMob Plugin for Google AdMob", "scripts": { "prepublish": "run-s clean build", diff --git a/plugin.xml b/plugin.xml index ac8d9aa7..e7638eee 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ + version="0.27.1" xmlns="http://apache.org/cordova/ns/plugins/1.0"> Cordova AdMob Plugin Robust, reliable and easy to use Cordova Admob plugin for Android and iOS phone. Allows preloading and automatic loading of interstitials and banners plus more. diff --git a/src/android/rewardvideo/RewardVideoExecutor.java b/src/android/rewardvideo/RewardVideoExecutor.java index 60eeb2a2..08e666f5 100644 --- a/src/android/rewardvideo/RewardVideoExecutor.java +++ b/src/android/rewardvideo/RewardVideoExecutor.java @@ -13,6 +13,8 @@ import org.apache.cordova.PluginResult; import org.json.JSONObject; +import java.util.List; + import name.ratson.cordova.admob.AbstractExecutor; import name.ratson.cordova.admob.AdMob; @@ -49,16 +51,28 @@ public void run() { Log.w("rewardedvideo", plugin.config.getRewardedVideoAdUnitId()); synchronized (rewardedVideoLock) { - if (!isRewardedVideoLoading) { - isRewardedVideoLoading = true; - Bundle extras = new Bundle(); - extras.putBoolean("_noRefresh", true); - AdRequest adRequest = new AdRequest.Builder() - .addNetworkExtrasBundle(AdMobAdapter.class, extras) - .build(); - rewardedVideoAd.loadAd(plugin.config.getRewardedVideoAdUnitId(), adRequest); - delayCallback.success(); + if (isRewardedVideoLoading) { + return; } + + isRewardedVideoLoading = true; + Bundle extras = new Bundle(); + extras.putBoolean("_noRefresh", true); + + final AdRequest.Builder adBuilder = new AdRequest.Builder() + .addNetworkExtrasBundle(AdMobAdapter.class, extras); + + final List testDevices = plugin.config.testDeviceList; + if (testDevices != null && !testDevices.isEmpty()) { + for (String deviceId : testDevices) { + adBuilder.addTestDevice(deviceId); + } + } + + final AdRequest adRequest = adBuilder.build(); + + rewardedVideoAd.loadAd(plugin.config.getRewardedVideoAdUnitId(), adRequest); + delayCallback.success(); } } });