Search code examples
androidadmobcocos2d-xrewardedvideoad

Multiple AdMob rewarded videos using cocos2dx (c++) on android API


I am trying to load multiple rewarded videos from AdMob in my app. It's on cocos2d-x (C++) and we extended atomic-plugin-ads's code to handle AdMob's Rewarded Videos. This means that we make JNI calls to Java to load the ads. Also, that our entire app runs through a single activity on Java side (AppActivity).

As Google's API for AdMob for rewarded videos uses a singleton object to load and show ads, I've managed to dispatch the callbacks from google's API to the correct ad units on my own.

How can I show one rewarded video ad while loading another at same time? I have one single Context from my single AppActivity, so I can get only one instance from MobileAds.getRewardedVideoAdInstance(context).

Example

Let's say that I have two ad units: AdUnit1 and AdUnit2. I have successfully loaded AdUnit1 (onAdLoaded() called). Now, I call loadAd() for AdUnit2.

Now my AdUnit1 is loaded and AdUnit2 is loading. At that moment, if I call isLoaded(), it returns false, and if I call show(), it does nothing.

I suspect that the singleton is in an internal state of "loading", so not considered loaded or ready to show. AdUnit1 is already loaded and I want to show it, but I can't specify the ad unit when calling show() or when checking isLoaded() in Google's API.

Is it possible to show one rewarded video ad while loading another at same time? Is there any alternative?


Solution

  • It is not currently possible to load more than one ad at a time from AdMob. You can show an ad and begin loading the next in onRewardedVideoAdClosed, but that's as close as it gets.