Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit 4d6ee29

Browse files
committed
feat: video-reward uses test devices
in js we have to send in our config a key with: ``` { testDevices: ['someId', 'someOtherId'] } ``` as per admob test devices config: https://developers.google.com/admob/android/test-ads#enable_test_devices chore: up plugin version chore: update docs
1 parent 3f99da2 commit 4d6ee29

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ While the Ionic community have provided [an Ionic Native Plugin](https://ionicfr
134134

135135
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.
136136

137+
## FAQ
138+
139+
### My video rewards are not working on test mode (Android).
140+
141+
You need to set your tests devices array. [AdMob official](https://developers.google.com/admob/android/test-ads#enable_test_devices) says:
142+
143+
In LogCat search for:
144+
```
145+
I/Ads: Use AdRequest.Builder.addTestDevice("33BE2250B43518CCDA7DE426D04EE231")
146+
to get test ads on this device."
147+
```
148+
`33BE2250B43518CCDA7DE426D04EE231` is your device id send it with your video reward config in this way:
149+
```
150+
config = {
151+
testDevices: ['33BE2250B43518CCDA7DE426D04EE231']
152+
}
153+
```
154+
137155
## Credits
138156

139157
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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-admob-free",
3-
"version": "0.27.0",
3+
"version": "0.27.1",
44
"description": "Cordova AdMob Plugin for Google AdMob",
55
"scripts": {
66
"prepublish": "run-s clean build",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<plugin xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-admob-free"
3-
version="0.27.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
3+
version="0.27.1" xmlns="http://apache.org/cordova/ns/plugins/1.0">
44
<name>Cordova AdMob Plugin</name>
55
<description>Robust, reliable and easy to use Cordova Admob plugin for Android and iOS
66
phone. Allows preloading and automatic loading of interstitials and banners plus more.

src/android/rewardvideo/RewardVideoExecutor.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.apache.cordova.PluginResult;
1414
import org.json.JSONObject;
1515

16+
import java.util.List;
17+
1618
import name.ratson.cordova.admob.AbstractExecutor;
1719
import name.ratson.cordova.admob.AdMob;
1820

@@ -49,16 +51,28 @@ public void run() {
4951
Log.w("rewardedvideo", plugin.config.getRewardedVideoAdUnitId());
5052

5153
synchronized (rewardedVideoLock) {
52-
if (!isRewardedVideoLoading) {
53-
isRewardedVideoLoading = true;
54-
Bundle extras = new Bundle();
55-
extras.putBoolean("_noRefresh", true);
56-
AdRequest adRequest = new AdRequest.Builder()
57-
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
58-
.build();
59-
rewardedVideoAd.loadAd(plugin.config.getRewardedVideoAdUnitId(), adRequest);
60-
delayCallback.success();
54+
if (isRewardedVideoLoading) {
55+
return;
6156
}
57+
58+
isRewardedVideoLoading = true;
59+
Bundle extras = new Bundle();
60+
extras.putBoolean("_noRefresh", true);
61+
62+
final AdRequest.Builder adBuilder = new AdRequest.Builder()
63+
.addNetworkExtrasBundle(AdMobAdapter.class, extras);
64+
65+
final List<String> testDevices = plugin.config.testDeviceList;
66+
if (testDevices != null && !testDevices.isEmpty()) {
67+
for (String deviceId : testDevices) {
68+
adBuilder.addTestDevice(deviceId);
69+
}
70+
}
71+
72+
final AdRequest adRequest = adBuilder.build();
73+
74+
rewardedVideoAd.loadAd(plugin.config.getRewardedVideoAdUnitId(), adRequest);
75+
delayCallback.success();
6276
}
6377
}
6478
});

0 commit comments

Comments
 (0)