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

feat: video-reward uses test devices (Android) #409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-admob-free"
version="0.27.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
version="0.27.1" xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>Cordova AdMob Plugin</name>
<description>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.
Expand Down
32 changes: 23 additions & 9 deletions src/android/rewardvideo/RewardVideoExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String> 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();
}
}
});
Expand Down