Appodeal: Ads not showing after GDPR implementation

I set up the recommended build code for the appodeal plugin and the appodeal init() command. Prior to these changes I was receiving ads with no problems. Now since the changes I do not receive ads at all.

Here is the init call, where appKey is either the Android or IOS key depending on the device.

appodeal.init( adListener, { appKey=appKey, hasUserConsent = global.userConsent} ) 

here is the plugin section of the gradle file:

      ["plugin.appodeal.beta.base"] =        { publisherId = 'com.coronalabs' },       -- Base         ['plugin.appodeal.beta.base'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.AmazonAds'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.GoogleAdMob'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.TwitterMoPub'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.StartApp'] = { publisherId = 'com.coronalabs' },       -- interstitial         ['plugin.appodeal.beta.AdColony'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.AppLovin'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.Chartboost'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.FacebookAudience'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.Flurry'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.InMobi'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.IronSource'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.Mobvista'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.MyTarget'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.StartApp'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.MillenialMedia'] = { publisherId = 'com.coronalabs' },         ['plugin.appodeal.beta.Ogury'] = { publisherId = 'com.coronalabs' },     },

and the permissions section:

    usesPermissions =     {       "android.permission.INTERNET",       "android.permission.ACCESS\_NETWORK\_STATE",       "android.permission.ACCESS\_WIFI\_STATE",       "android.permission.ACCESS\_COARSE\_LOCATION",       "android.permission.ACCESS\_FINE\_LOCATION",       "android.permission.WRITE\_EXTERNAL\_STORAGE",       "android.permission.VIBRATE",       "com.android.vending.CHECK\_LICENSE",       "com.android.vending.BILLING"     },

other than adding code to gather the user response for the global.userConsent parameter, which is working successfully, and changing the init call to the format listed above there have been no changes that should have caused the adds to stop showing.

Could this be an issue with the appKey value? Should I create a new one?

Why are you manually adding all those permissions? My guess is that “global.userConsent” is probably nil at the time you initialize appodeal. Are you seeing any errors in the logs? I have done two builds today in iOS with the new version and don’t have any problems seeing ads.

The userConsent is fine and is stored in the game state json file for validation on game startup to prevent the request screen from coming up on following game initiation after the selection has been made on first play.

As for manually adding the permissions, I am still relatively new to this. This is my first game so if there is a better way please let me know.

You don’t need to provide those permissions unless you are using them outside the plugins. I would remove them. They get added automatically. Can you print that value of user.global consent before the init? Also what does the logs say? Set debug mode to true for the appodeal plugin.

In testing I see that the init is good and that the show is being called, still no ads when I load a production build to my phone.

the appodel show call is successful but nothing is displayed. Cannot generate a log from the device as I do not have wi-fi to feed back to my desktop. and I cannot get any print statements to display from the adListener. Cannot get the event.phase to print at the top of the listener. Which make no sense as I can see the init and the isLoaded and the show display the warning to build for the device. Which to me would indicate that they are being called/executed successfully.

can you post your code? the event listener and where you call the listener? No logs from the device? Did you use a cable to push the build to the device? Why can’t you use either the corona console or the adb monitor to look at the log stream?

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?

Why are you manually adding all those permissions? My guess is that “global.userConsent” is probably nil at the time you initialize appodeal. Are you seeing any errors in the logs? I have done two builds today in iOS with the new version and don’t have any problems seeing ads.

The userConsent is fine and is stored in the game state json file for validation on game startup to prevent the request screen from coming up on following game initiation after the selection has been made on first play.

As for manually adding the permissions, I am still relatively new to this. This is my first game so if there is a better way please let me know.

You don’t need to provide those permissions unless you are using them outside the plugins. I would remove them. They get added automatically. Can you print that value of user.global consent before the init? Also what does the logs say? Set debug mode to true for the appodeal plugin.

In testing I see that the init is good and that the show is being called, still no ads when I load a production build to my phone.

the appodel show call is successful but nothing is displayed. Cannot generate a log from the device as I do not have wi-fi to feed back to my desktop. and I cannot get any print statements to display from the adListener. Cannot get the event.phase to print at the top of the listener. Which make no sense as I can see the init and the isLoaded and the show display the warning to build for the device. Which to me would indicate that they are being called/executed successfully.

can you post your code? the event listener and where you call the listener? No logs from the device? Did you use a cable to push the build to the device? Why can’t you use either the corona console or the adb monitor to look at the log stream?