So, failing to do reward ads in my app.
My code (shamelesly copied/pasted from the example:
local function adListener( event )
local json = require( "json" )
print("Ad event: ")
print( json.prettify( event ) )
if ( event.phase == "init" ) then -- Successful initialization
print( event.provider )
admob.load( "rewardedVideo", { adUnitId = myRewardedAdUnitId, hasUserConsent = false } )
elseif event.phase == "failed" then
if event.type == "rewardedVideo" then
-- Put your ad loading failover code here
print("We failed to load the rewardedVideo")
end
elseif ( event.phase == "displayed" ) then -- Ads were loaded
if event.type == "rewardedVideo" then
print("------ We will now do again the load for the rewarded video")
admob.load( "rewardedVideo", { adUnitId = myRewardedAdUnitId, hasUserConsent = false } )
end
elseif ( event.phase == "reward" ) then -- A rewarded video was completed
local data = json.decode( event.data )
local rewardAmount = data.rewardAmount
local rewardItem = data.rewardItem
printTable("reward data back", data)
-- code to give these to your user
upgradeSkill(rewardItem)
end
end
-
(Even though documentation says otherwise), having testMode =true does load the ad (I keep on seeing the chancelor of Germany), for 1-2 seconds, and then it closes. (According to documentation it should return a failed event, but I don’t see one).
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxx\/yyyyyyyyyy”}",
: “name”:“adsRequest”,
: “phase”:“displayed”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
: ------ We will now do again the load for the rewarded video
: plugin.admob: Test mode active for device ‘D________________’
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxx\/yyyyyyyyyy”}",
: “name”:“adsRequest”,
: “phase”:“closed”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxx\/yyyyyyyyyy”}",
: “name”:“adsRequest”,
: “phase”:“loaded”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
- When I change the testMode to “false”, (as the documentation says for testing rewardAds),
I get just a blank screen the moment that the ad should start.
: Ad event:
: {
: “name”:“adsRequest”,
: “phase”:“init”,
: “provider”:“admob”,
: “isError”:false
: }
: admob
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxxx\/zzzzzzzzz”}",
: “name”:“adsRequest”,
: “phase”:“loaded”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
: ####### here we will show an ad
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxxx\/zzzzzzzzz”}",
: “name”:“adsRequest”,
: “phase”:“displayed”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
: ------ We will now do again the load for the rewarded video
Here the screen goes black, and nothing happens. The only thing I can do is to go back (by the android button), in which case this happens:
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxxx\/zzzzzzzzz”}",
: “name”:“adsRequest”,
: “phase”:“loaded”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
: }
: Ad event:
: {
: “data”:"{“adUnitId”:“ca-app-pub-xxxxxxxxxxxxxxxx\/zzzzzzzzz”}",
: “name”:“adsRequest”,
: “phase”:“closed”,
: “provider”:“admob”,
: “type”:“rewardedVideo”,
: “isError”:false
Update: The whole minimum code that is needed (without the app_id and the ad_unit_id) can be found at: https://github.com/koyan/solar2d-rewardad
What am I missing?
Thanks