Problem with purchase and ads

Hi,

For a few hours, my purchase function and ads are not working anymore although I have made no changes in my code.

And all these worked normally yesterday…

Here is my code for the ads:

local ads = require( "ads" ) local bannerAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnnn" --for your iOS banner local interstitialAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnn" --for your iOS interstitial if ( system.getInfo( "platformName" ) == "Android" ) then bannerAppID = "ca-app-pub-------------------------" --for your Android banner interstitialAppID = " ca-app-pub---------------------------" --for your Android interstitial print("entered ads1") end local adProvider = "admob" local function adListener( event ) -- The 'event' table includes: -- event.name: string value of "adsRequest" -- event.response: message from the ad provider about the status of this request -- event.phase: string value of "loaded", "shown", or "refresh" -- event.type: string value of "banner" or "interstitial" -- event.isError: boolean true or false print("entered ads2") local msg = event.response -- Quick debug message regarding the response from the library print( "Message from the ads library: ", msg ) if ( event.isError ) then print( "Error, no ad received", msg ) myData.gotAnAdd = "false" else print( "Ah ha! Got one!" ) myData.gotAnAdd = "true" end end ads.init( adProvider, bannerAppID, adListener ) if (iap.getInventoryValue("unlock")~=true) then if myData.gotAnAdd == "true" then print("Displaying an ad") ads.show( "banner", { x=0, y=1750, appId=bannerAppID } ) end end

And, it seems that the function adListener is never entered as “entered ads2” is never printed in the console log. And there is no error in the console log apart from “ERROR: Unable to resolve host “stats.coronalabs.com”: No address associated with hostname”.

Thanks in advance for your replies

Pierre

Sorry, the purchase works fine in fact.

But, the ads are still not working…

Can you post your console log from the run?

Rob

Here it is:

V/Corona ( 6606): \> Class.forName: network.LuaLoader V/Corona ( 6606): \< Class.forName: network.LuaLoader V/Corona ( 6606): Loading via reflection: network.LuaLoader I/Corona ( 6606): Platform: SM-G361F / ARM Neon / 5.1.1 / Vivante GC7000UL / OpenGL ES 3.0 / 2016.2906 / français | FR | fr\_FR | fr V/Corona ( 6606): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona ( 6606): ok I/Corona ( 6606): true I/Corona ( 6606): ok I/Corona ( 6606): WARNING: licensing.init() was already called for google. I/Corona ( 6606): entered ads1 V/Corona ( 6606): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): \> Class.forName: plugin.google.iap.v3.LuaLoader V/Corona ( 6606): \< Class.forName: plugin.google.iap.v3.LuaLoader V/Corona ( 6606): Loading via reflection: plugin.google.iap.v3.LuaLoader I/Corona ( 6606): I/Corona ( 6606): mainmenu: create event I/Corona ( 6606): mainmenu: show event I/Corona ( 6606): ok1 I/Corona ( 6606): nil I/Corona ( 6606): ok2 I/Corona ( 6606): main menu has well appeared 33333 V/Corona ( 6606): \> Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader I/Corona ( 6606): main loaded I/Corona ( 6606): myData.settings.alreadyChosen I/Corona ( 6606): true

You need to put in some prints to print the values you’re testing in these two if statements:

if (iap.getInventoryValue("unlock")~=true) then if myData.gotAnAdd == "true" then print("Displaying an ad") ads.show( "banner", { x=0, y=1750, appId=bannerAppID } ) end end

What is iap.getInventoryValue(“unlock”)?

What is the value of myData.gotAnAdd?

iap.getInventoryValue(“unlock”) refers to whether the article has been purchased by the user and if I should remove the ads.

And, if an ad was generated, “Ah ha! Got one!” would be printed.

I will add the print statements as soon as I can.

And isn’t it due to the update they made for corona ads as it worked normally before?

You are using AdMob not Corona Ads. They are different plugins.

As for my question about the variables. I wasn’t asking about their purpose, but I was curious about their values. If the value of iap.getInventoryValue(“unlock”) is false, you won’t attempt to show an ad. If the value of myData.gotAnAdd  isn’t the string “true”, not the boolean value true, it won’t show an ad. I suspect this is the problems. You probably want true not “true” in that if statement.

Sorry, the purchase works fine in fact.

But, the ads are still not working…

Can you post your console log from the run?

Rob

Here it is:

V/Corona ( 6606): \> Class.forName: network.LuaLoader V/Corona ( 6606): \< Class.forName: network.LuaLoader V/Corona ( 6606): Loading via reflection: network.LuaLoader I/Corona ( 6606): Platform: SM-G361F / ARM Neon / 5.1.1 / Vivante GC7000UL / OpenGL ES 3.0 / 2016.2906 / français | FR | fr\_FR | fr V/Corona ( 6606): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona ( 6606): ok I/Corona ( 6606): true I/Corona ( 6606): ok I/Corona ( 6606): WARNING: licensing.init() was already called for google. I/Corona ( 6606): entered ads1 V/Corona ( 6606): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.ads.admob.LuaLoader V/Corona ( 6606): \> Class.forName: plugin.google.iap.v3.LuaLoader V/Corona ( 6606): \< Class.forName: plugin.google.iap.v3.LuaLoader V/Corona ( 6606): Loading via reflection: plugin.google.iap.v3.LuaLoader I/Corona ( 6606): I/Corona ( 6606): mainmenu: create event I/Corona ( 6606): mainmenu: show event I/Corona ( 6606): ok1 I/Corona ( 6606): nil I/Corona ( 6606): ok2 I/Corona ( 6606): main menu has well appeared 33333 V/Corona ( 6606): \> Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona ( 6606): \< Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona ( 6606): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader I/Corona ( 6606): main loaded I/Corona ( 6606): myData.settings.alreadyChosen I/Corona ( 6606): true

You need to put in some prints to print the values you’re testing in these two if statements:

if (iap.getInventoryValue("unlock")~=true) then if myData.gotAnAdd == "true" then print("Displaying an ad") ads.show( "banner", { x=0, y=1750, appId=bannerAppID } ) end end

What is iap.getInventoryValue(“unlock”)?

What is the value of myData.gotAnAdd?

iap.getInventoryValue(“unlock”) refers to whether the article has been purchased by the user and if I should remove the ads.

And, if an ad was generated, “Ah ha! Got one!” would be printed.

I will add the print statements as soon as I can.

And isn’t it due to the update they made for corona ads as it worked normally before?

You are using AdMob not Corona Ads. They are different plugins.

As for my question about the variables. I wasn’t asking about their purpose, but I was curious about their values. If the value of iap.getInventoryValue(“unlock”) is false, you won’t attempt to show an ad. If the value of myData.gotAnAdd  isn’t the string “true”, not the boolean value true, it won’t show an ad. I suspect this is the problems. You probably want true not “true” in that if statement.