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
How to fix it?
There're events like 'Event.APPLICATION_BACKGROUND', 'Event.APPLICATION_RESUME', etc.
http://docs.giderosmobile.com/reference/gideros/EventDispatcher/Event.APPLICATION_BACKGROUND#Event.APPLICATION_BACKGROUND
"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)
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.
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.
"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)
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.
Likes: antix
"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)
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
My guess is that the issue they're flagging is unavoidable with the ad network you're running. Which network is it?
Likes: PaulR
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?
Likes: antix
https://deluxepixel.com
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
https://deluxepixel.com