Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to prevent the interstitial ads showing outside the the app? — Gideros Forum

How to prevent the interstitial ads showing outside the the app?

XmanXman Member
edited November 2018 in General questions
I get an email from google play says my app showing interstitial ads outside of the app environment.
I can not understand why this can happen.
Even if I show interstitial ads after a tween complete or a timer timeout, when the user suspend the app by press the home button of the device, the app enter to the background, the tween or the timer will also paused and the interstitial will not triggered.

Comments

  • Has anybody get this kind of violation notification from google?
    How to fix it?
  • Apollo14Apollo14 Member
    edited November 2018
    Hi!
    There're events like 'Event.APPLICATION_BACKGROUND', 'Event.APPLICATION_RESUME', etc.
    http://docs.giderosmobile.com/reference/gideros/EventDispatcher/Event.APPLICATION_BACKGROUND#Event.APPLICATION_BACKGROUND
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • XmanXman Member
    edited November 2018
    Thanks for your reply.
    I want to make sure what can cause the interstitial ads showing outside of the app.

    I use the code as:

    Timer.delayedCall(5000, function() showInterstitial() end)

    or

    GTween.new(self, 5, {scaleX = 1}, {delay = 1.5, onComplete = function() showInterstitial() end})

    If the app is moved to background before the timer timeout or the tween completed, It's not possible to trigger these events to show the interstitial ads.


  • talistalis Guru
    edited November 2018
    Not an answer to the cause of this but just as imple fix that can work;
    1-Define a global checking variable called AdShowing, and set it to false.
    2-On the event that @Apollo14 wrote 'Event.APPLICATION_BACKGROUND set this logical parameter to false also, only set it to true when application_resume event fire and when Gtween finished.
    3-Nest your Timer.delayedCall funsction inside a if(AdShowing) then ....

    It seems a dirty fix but will guarantee that your app will never ever fire the ads when in the background.


  • adsAllowed=true
     
    stage:addEventListener(Event.APPLICATION_BACKGROUND, function()
    	adsAllowed=false
    end)
     
    Timer.delayedCall(5000, function()
    	if adsAllowed==true then
    		showInterstitial()
    	end
    end)
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • Yes, obviously, this can work.
    But I'm afraid if the Event.APPLICATION_BACKGROUND is already triggered, the timer event should not trigger in the background. So I still afraid this can not prevent the issue. The google team have not told me what exact steps to cause the ads showing outside of the app.
  • google team never says anything useful

    Likes: antix

    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
    +1 -1 (+1 / -0 )Share on Facebook
  • @xman maybe if you have an event code firing when the application is suspended.. call pauseAll() (http://docs.giderosmobile.com/reference/gideros/Timer/pauseAll) to stop any further adverts firing, and also stop any currently playing advert with hideAd(adType).

    You would also have an event code fire when the application is resumed (http://docs.giderosmobile.com/reference/gideros/EventDispatcher/Event.APPLICATION_RESUME#Event.APPLICATION_RESUME) and call showAd(adType) to get the ads rolling again, and call resumeAll() (http://docs.giderosmobile.com/reference/gideros/Timer/resumeAll#Timer.resumeAll) to get your timers going again too.

    Likes: Apollo14

    +1 -1 (+1 / -0 )Share on Facebook
  • totebototebo Member
    edited November 2018
    I think Google might be on a crusade to make developers only use Admob as an ad network. I have also had strange issues with the ads that stopped as soon as I removed all networks apart from Admob.

    My guess is that the issue they're flagging is unavoidable with the ad network you're running. Which network is it?

    Likes: PaulR

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • I only use Admob.
    And theoretically speaking, Gideros will not run code in background, so as soon as the enter to background event is triggered, all timers and tweens will stop automatically, is that right?
  • Then I really don't know why they have flagged it. Yes, as far as I know Gideros exported apps are self-contained. So it's likely that the issue that's been reported is relating to something else, I really don't think it's to do with the plugin or code. All my apps use Admob, and whilst they have been removed for various arbitrary reasons, that reason hasn't yet been flagged for me.

    Likes: antix

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • I think so, but you should pause any music as that will carry on otherwise.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Thinking about it though - you get the suspend event as the app is suspending - maybe timers still function outside whilst in sleep?

    Maybe you should set a 'paused' flag on suspend and unset it on resume - then in your timer check if paused or not?

    Likes: antix

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.