Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Admob banners disappear after Interstitial is loaded — Gideros Forum

Admob banners disappear after Interstitial is loaded

totebototebo Member
edited July 2014 in Bugs and issues
Title says it all. Here is the flow in more detail:

1. Admob "smart_banner" and Chartboost "interstitial" are loaded when app starts.
2. After a certain amount of sprites have been added to the stage the Admob banner is unloaded and trigger Event.AD_DISMISSED. If no sprites are added to the stage this doesn't happen.
3. Once the banner has been dismissed it cannot be shown again without first loading it again.

Notes:

- If no interstitial is loaded the banners work as expected
- If the banner load is delayed to after the interstitial has loaded it works as expected UNTIL the interstitial is shown and dismissed. After this happens it is again unloaded when a certain amount of sprites are added to the stage.
- If Admob test ads are used the banners work as expected

Has anyone seen this before? Could it be that, because the test ads work, this would work in production? Any thoughts on this would be great.

Cheers,

Niclas
My Gideros games: www.totebo.com

Comments

  • @totebo I encountered some similar strange behavior once for one of the clients, and the problem was that Ads instance was defined as local variable and was garbage collected later on.

    Could that be it? :)
  • I didn't use local variables, but I stored the "currently active" network in one variable, and I think this caused conflicts. I have now rewritten the entire ad manager separating each ad network, and it works. :)

    Likes: ar2rsawseen

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Hey Totebo,

    Any chance you could share more of your code on this please?

    I just found this thread through googling the exact same problem.

    Loading an interstitual ad between banners causes the second banner to disappear.

    Thanks!!
  • Tom2012Tom2012 Guru
    edited September 2015
    At the moment I'm using scene manager and have this code:
    	self.banner = Ads.new("admob")
    	self.banner:setKey("123/456")
    	self.banner:loadAd("banner", "ca-app-pub-123/456")
    	self.banner:enableTesting()
     
    	self.banner:addEventListener(Event.AD_RECEIVED, function() 
    		print("received banner ad")
    	end)
     
    	self.banner:addEventListener(Event.AD_FAILED, function(e) 
    		print("ad failed",e.error)	
    	end)
    Sounds like I'm getting conflicts but I don't understand why. Thanks
  • totebototebo Member
    edited September 2015
    Hi Tom, could you send the code interstitial code too?

    My guess is that you create a separate instance of Admob for banners and interstitials. Although this would make sense, it doesn't work. Instead you have to use only one instance of each ad network and check whether it's an interstitial or banner when an event is returned.

    Likes: Tom2012

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • My guess is that you create a separate instance of Admob for banners and interstitials. Although this would make sense, it doesn't work. Instead you have to use only one instance of each ad network and check whether it's an interstitial or banner when an event is returned.
    That solved it. How did I miss that :)

    Thanks very much Totebo! Working fine now. Making more than one instance of adMob causes weird bugs.

  • Nice one! :)
    My Gideros games: www.totebo.com
  • @totebo I'm in the process of rewriting my ad manager too. I will bear this in mind. Do you have any more tips?

    I did come across an issue when showing Applovin banners. The ad refresh would sometimes show a new ad and blank the rest of the screen. The app was running underneath though. I decided to remove Applovin banners as it was only a temporary fix until we get our Admob account issues resolved!!
  • I haven't seen that issue with Applovin (or other networks) I'm afraid.

    I've since restructured how I serve ads a few times, and I'm now running a system where I have each network as a separate class, so I can easily load one and when that fails fall back on another network. Another benefit is that I can change the order in which the ad networks load easily, to maximise profit.
    My Gideros games: www.totebo.com
  • Tom2012Tom2012 Guru
    edited September 2015
    For anyone in the future, here's the code I've used to get Admob working. I'd imagine it would work for other networks too.

    I'm using scene manager...

    in main.lua:
    -- Setup Ads
     
    -- setup admob
     
    admob = Ads.new("admob")
    admob:enableTesting()
     
    admob:addEventListener(Event.AD_RECEIVED, function(e) 
    	if(adType=="interstitial") then
    		adReceived = true
    	end
    end)
     
    admob:addEventListener(Event.AD_FAILED, function(e) 
    	print("ad failed",e.error)
    	adReceived = nil
    end)
     
    function changeScene()
     
    	print("changeScene function called")
    	print("ad type", adType)
     
    	if(adType=="interstitial") then
     
    		sceneManager:changeScene(nextScene, 0, SceneManager.flipWithFade, easing.outBack)
     
    	end
     
    end
     
    admob:addEventListener(Event.AD_ACTION_END, changeScene, stage)
    admob:addEventListener(Event.AD_ACTION_END, changeScene, stage)
    admob:addEventListener(Event.AD_DISMISSED, changeScene, stage)
    Code to show interstitial ad, placed on the scene
    	-- setup ad
     
    	adType = "interstitial"
    	nextScene = nil
    	adReceived = nil
    	-- setup ad
     
    	admob:setKey("12345/6789")
    	admob:loadAd("interstitial", "ca-app-pub-12345/6789")
    admob:showAd("interstitial")
    On the scene where a banner is required:
    	adType = "banner"
    	admob:setKey("22334455/66778899")
    	admob:loadAd("banner", "ca-app-pub-22334455/66778899")
    	admob:showAd("banner")
    To hide ads it's
    	admob:hideAd("banner")
    or
    	admob:hideAd("interstitial")
    Manually setting a global variable of adType = "interstitial" for example, before each ad is shown, helps keep track of which ad is showing. This is useful because any functions you set up with Event.AD_RECEIVED will fire whether a banner or an interstitial is shown.

    In my case, I didn't want to change scene after a banner is shown. :)
Sign In or Register to comment.