ads.isLoaded("interstitial") Android never works

i am trying to make ads.isLoaded(“interstitial”) works on android but it seems to be not working . or may be return false all the time .

here is my code

AdmobShown=0 VungleShown=0 charboot=0 ShowAds = function () ga.event("Ads Function") ads:setCurrentProvider( "vungle" ) if ads.isAdAvailable() then ads.show( "interstitial" ) ga.event("Vungel Ads Shown") VungleShown=1 else ads:setCurrentProvider( "admob" ) if ( ads.isLoaded("interstitial") ) then print("AdMob Set Provider") ads.show("interstitial") ga.event("AdMob Ads Shown") print("AdMob SHow be showned now Ads") AdmobShown=1 end if AdmobShown==0 and VungleShown==0 then ga.event("Ads chartboost Shown") chartboost.show( "interstitial", "Main Menu" ) end end end

i tried it alone and still not working . i mean like

if ( ads.isLoaded("interstitial") ) then ads.show("interstitial") ga.event("AdMob Ads Shown") end

when i directly show the ads it show without any problem

build is 2016.2929

Tutorial: Implementing AdMob | Corona Labs

it is clearly show that i can use that ,so what do you mean by your link ?

"Since your callback function will trigger when the ad is loaded, you could theoretically set a flag and later check the flag to determine if the ad is ready to show. However, Corona provides an additional convenience function called ads.isLoaded(), so when you’re ready to show the ad, simply call:

 

if ( ads.isLoaded("interstitial") ) then ads.show("interstitial") end

i tried with many ways . the listener never fire the event

function AdmobListener(event)   print("AdmobListener Fired")     if ( event.isError ) then         AdmobCanShowNow=0         print("AdmobCanShowNow=0 this is everErr")         print(AdmobCanShowNow)     elseif ( event.phase == "loaded" ) then         AdmobCanShowNow=1         print("AdmobCanShowNow=1 this is eventPhase loaded")         print(AdmobCanShowNow)     elseif ( event.phase == "shown" ) then         -- the ad was viewed and closed     end end    ads.init("admob", "ca-app-pub-3940256099942544/1033173712", AdmobListener)-- the Default Dummy ID By Google    ads.load("admob", "ca-app-pub-3940256099942544/1033173712")--the Default Dummy ID By Google

i already add this to the Main lua file .

and i am using logcat to show the print MSG .

when i use ads.show(“interstitial”) it work perfect but when i try to check with the is.load or the is.loaded and the event listener it never fire

When you call .isLoaded() it doesn’t loop or wait for the ad to be loaded. It only checks in that instance. ads.show() will tell the add to show when its ready. Or once you get an “loaded” event phase, you know it’s loaded and you can then call ads.show().

Rob

ok i will try something and get back to you

Thanks Rob

Rob . i dont get it yet

see my code :

ShowAdsF = function () ads:setCurrentProvider( "admob" ) if ( ads.isLoaded("interstitial") ) then ads.show("interstitial") else print(" Not Shown again") end end

this didnot work . it is so simple

is there is any wrong with this function ?

i put this in main

ads.init("admob", "ca-app-pub-3940256099942544/1033173712")-- the Default Dummy ID By Google ads.load("admob", "ca-app-pub-3940256099942544/1033173712")--the Default Dummy ID By Google 

still it didnot work . i am not waiting the ads to load . i am just checking if it loaded then show else i have to chose another ad provider

When you call “ShowAdsF()”, you are calling it once at that instant. If the ad is not loaded at that point, your “if” statement hits the “else” clause and the function ends and you’re not informed that the ad is loaded. A few milliseconds later, the ad loads, but you never go back and re-check to see if it’s loaded. It’s a one-time-at-that-microsecond check.

Rob

Aha , i got it now . Thanks Rob

here is how i implement it now using delay

ShowAdsF = function () ga.event("Ads Function") ads:setCurrentProvider( "admob" ) ads.show( "interstitial" ) timer.performWithDelay(500,ShowAdmobOnly()) end ShowAdmobOnly= function () if ( ads.isLoaded("interstitial") ) then ads.show( "interstitial" ) ga.event("AdMob Ads Shown") print ("loaded Admob") else chartboost.show( "interstitial", "Main Menu" ) ga.event("chartboost Ads Shown") end end 

and it works !

Tutorial: Implementing AdMob | Corona Labs

it is clearly show that i can use that ,so what do you mean by your link ?

"Since your callback function will trigger when the ad is loaded, you could theoretically set a flag and later check the flag to determine if the ad is ready to show. However, Corona provides an additional convenience function called ads.isLoaded(), so when you’re ready to show the ad, simply call:

 

if ( ads.isLoaded("interstitial") ) then ads.show("interstitial") end

i tried with many ways . the listener never fire the event

function AdmobListener(event)   print("AdmobListener Fired")     if ( event.isError ) then         AdmobCanShowNow=0         print("AdmobCanShowNow=0 this is everErr")         print(AdmobCanShowNow)     elseif ( event.phase == "loaded" ) then         AdmobCanShowNow=1         print("AdmobCanShowNow=1 this is eventPhase loaded")         print(AdmobCanShowNow)     elseif ( event.phase == "shown" ) then         -- the ad was viewed and closed     end end    ads.init("admob", "ca-app-pub-3940256099942544/1033173712", AdmobListener)-- the Default Dummy ID By Google    ads.load("admob", "ca-app-pub-3940256099942544/1033173712")--the Default Dummy ID By Google

i already add this to the Main lua file .

and i am using logcat to show the print MSG .

when i use ads.show(“interstitial”) it work perfect but when i try to check with the is.load or the is.loaded and the event listener it never fire

When you call .isLoaded() it doesn’t loop or wait for the ad to be loaded. It only checks in that instance. ads.show() will tell the add to show when its ready. Or once you get an “loaded” event phase, you know it’s loaded and you can then call ads.show().

Rob

ok i will try something and get back to you

Thanks Rob

Rob . i dont get it yet

see my code :

ShowAdsF = function () ads:setCurrentProvider( "admob" ) if ( ads.isLoaded("interstitial") ) then ads.show("interstitial") else print(" Not Shown again") end end

this didnot work . it is so simple

is there is any wrong with this function ?

i put this in main

ads.init("admob", "ca-app-pub-3940256099942544/1033173712")-- the Default Dummy ID By Google ads.load("admob", "ca-app-pub-3940256099942544/1033173712")--the Default Dummy ID By Google 

still it didnot work . i am not waiting the ads to load . i am just checking if it loaded then show else i have to chose another ad provider

When you call “ShowAdsF()”, you are calling it once at that instant. If the ad is not loaded at that point, your “if” statement hits the “else” clause and the function ends and you’re not informed that the ad is loaded. A few milliseconds later, the ad loads, but you never go back and re-check to see if it’s loaded. It’s a one-time-at-that-microsecond check.

Rob

Aha , i got it now . Thanks Rob

here is how i implement it now using delay

ShowAdsF = function () ga.event("Ads Function") ads:setCurrentProvider( "admob" ) ads.show( "interstitial" ) timer.performWithDelay(500,ShowAdmobOnly()) end ShowAdmobOnly= function () if ( ads.isLoaded("interstitial") ) then ads.show( "interstitial" ) ga.event("AdMob Ads Shown") print ("loaded Admob") else chartboost.show( "interstitial", "Main Menu" ) ga.event("chartboost Ads Shown") end end 

and it works !