Appodeal: Ads not showing after GDPR implementation

Are you printing out the values of the “event” table in your ad listener function and looking at those messages on your device’s console log?

There is a lot of useful information that can be gotten from that. Without it, you’re just guessing at what the problems are.

Rob

Listener and calling init code:

local function adListener( event )   print("listener: event: ", event.phase)   -- Successful initialization of the Appodeal plugin   if ( event.phase == "init" ) then      print( "Appodeal event: initialization successful" )     print(event.isError)      -- An ad loaded successfully elseif ( event.phase == "loaded" ) then print( "Appodeal event: " .. tostring(event.type) .. " ad loaded successfully" ) -- The ad was displayed/played elseif ( event.phase == "displayed" or event.phase == "playbackBegan" ) then print( "Appodeal event: " .. tostring(event.type) .. " ad displayed" ) -- The ad was closed/hidden/completed elseif ( event.phase == "hidden" or event.phase == "closed" or event.phase == "playbackEnded" ) then print( "Appodeal event: " .. tostring(event.type) .. " ad closed/hidden/completed" )      --    if( event.type == "rewardedVideo" and event.phase == "playbackEnded" ) then --      local currentScene = composer.getSceneName("overlay") --      --print("CURRENT SCENE : ", currentScene) --      if(currentScene == "scenes.nextlevel") then --        local scene = composer.getScene(currentScene) --        scene:onRewardComplete() --      end --    end -- The user clicked/tapped an ad elseif ( event.phase == "clicked" ) then print( "Appodeal event: " .. tostring(event.type) .. " ad clicked/tapped" ) -- The ad failed to load elseif ( event.phase == "failed" ) then print( "Appodeal event: " .. tostring(event.type) .. " ad failed to load" )        -- The ad event data received   elseif ( event.phase == "dataReceived" ) then      print( "Appodeal event: " .. tostring(event.type) .. " ad returned data : " .. tostring(event.data) )   end end

GDPR handler and init() call:

-- -- call EEA/GDPR consent handler --   fOpen.loadStateFile()   global.userConsent = global.gameState[global.GDPR].userConsent   local consentDate = global.gameState[global.GDPR].userConsentDate   local markDate = "01-01-2100" --  --print("BASE: consentDate: ",consentDate)   today = os.date("%m-%d-%Y")      --print("BASE: consentDate: ",consentDate)   --print("BASE: today: ",today)   --print("main: appKey: ",appKey)   if ( consentDate == markDate) then ----    print("main: calling privacyPolicy")     composer.gotoScene("scenes.privacyPolicy",{time = 1500, effect = "crossFade" }) ----    print("main: userConsent is: ",global.userConsent) ---- Initialize the Appodeal plugin     appodeal.init( adListener, { appKey=appKey, supportedTypes = {"interstitial"}, hasUserConsent = global.userConsent, } ) -- how to get data to appodeal? [in a parameter in the initialize() call   elseif ( consentDate ~= markDate) then     appodeal.init( adListener, { appKey=appKey, supportedTypes = {"interstitial"}, hasUserConsent = global.userConsent,}) -- hasUserConsent = global.userConsent, testMode = true, supportedTypes = {"interstitial"}} ) -- normal init, consent already set     --print("in main calling splash: ")     composer.gotoScene( "scenes.splashScreen", {time = 333, effect = "crossFade" })  

What I get in console:

18:32:39.392  appodeal.init() WARNING: The Appodeal plugin is only supported on Android and iOS devices. Please build for device

18:41:49.007  before ad: count is: 6

18:41:49.007  calling ad

18:41:49.007  appodeal.isLoaded() WARNING: The Appodeal plugin is only supported on Android and iOS devices. Please build for device

As you can see no listener info and no show() call even though the isLoaded() check passes, see code below. Or does it?

The overall changes to the code were minimal when putting in the GDPR code. Ads were functioning fine until then. This is the only call made in the code other than the init() call, this happens when the player completes every 3rd game and they are exiting the score review scene.

       if (global.gamesPlayed % 3 == 0) then           print("calling ad")           if (appodeal.isLoaded("interstitial")) then             print("is loaded")             appodeal.show("interstitial")           end         end

You need to build and deploy to an actual device otherwise you get this warning. 

WARNING: The Appodeal plugin is only supported on Android and iOS devices. Please build for device

This is what my listener looks like for reference: 

A.appodealListerner = function( event ) local appodeal = require( "plugin.appodeal" ) if event.phase == "init" then -- Successful initialization A.showBanner() elseif event.data ~= nil and event.type == "rewardedVideo" and event.data.name == "reward" and event.phase == "playbackEnded" then A.eventDispatcher:dispatchEvent( { name="rewarded", data=true } ) elseif event.type == "rewardedVideo" and event.phase == "closed" then A.eventDispatcher:dispatchEvent( { name="rewarded", data=false } ) end end

And here is my init:

appodeal.init( A.appodealListerner, { appKey=appodealId, testMode=false, hasUserConsent=consent } )

yup I understand that however, when I build and deploy to my phone, with ‘USB Debugging’ turned on and the USB cable attached I get nothing from the app on the console.

So why are you requiring the plugin inside the listener function? You should have already required it (near the top of the app) so you can call appodeal.init() to pass it a listener function?

Next, you should require the json module near the top of your code:

local json = require(“json”)

Then inside your listener function:

A.appodealListerner = function( event ) print( json.prettify( event ) ) if event.phase == "init" then -- Successful initialization

That way you know what phase you’re getting, any response messages from the server etc.

As far as getting console log messages, if you’re on a Mac, you can choose to have Corona install your app to your device at which point, the device’s console log will be routed to the Corona console log as long as you don’t close the dialog box. But if you’re on Windows, or you’re running while not having Corona’s console attached to, then you either have to actively run “adb logcat” from the command line (you will have to install the ADB tools) or use Android Studio which I believe can also look at the device’s console log.

Rob

Ok, so found some errors in the build.settings file cleaned them up. Verified that I had the init() statement set for the beta format for GDPR.

Now I get this error when trying to launch, note the requires for the aoopdeal plugin is at line 18 in the main scene.

?:0:attempt to call a nil value 

stack traceback:

?:in function ‘require’

main.lua:18: in main chunk

When I rollback to the legacy version I get ads but since GDPR is false they are general not targeted as expected.

Can you share your current code?