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

Commit f8cf85e

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 f8cf85e

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
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.

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: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,28 @@ public void run() {
4949
Log.w("rewardedvideo", plugin.config.getRewardedVideoAdUnitId());
5050

5151
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();
52+
if (isRewardedVideoLoading) {
53+
return;
6154
}
55+
56+
isRewardedVideoLoading = true;
57+
Bundle extras = new Bundle();
58+
extras.putBoolean("_noRefresh", true);
59+
60+
final AdRequest.Builder adBuilder = new AdRequest.Builder()
61+
.addNetworkExtrasBundle(AdMobAdapter.class, extras);
62+
63+
final List<String> testDevices = plugin.config.testDeviceList;
64+
if (testDevices != null && !testDevices.isEmpty()) {
65+
for (String deviceId : testDevices) {
66+
adBuilder.addTestDevice(deviceId);
67+
}
68+
}
69+
70+
final AdRequest adRequest = adBuilder.build();
71+
72+
rewardedVideoAd.loadAd(plugin.config.getRewardedVideoAdUnitId(), adRequest);
73+
delayCallback.success();
6274
}
6375
}
6476
});

0 commit comments

Comments
 (0)