Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
No Internet connection, problem with Ads — Gideros Forum

No Internet connection, problem with Ads

yubaroyubaro Member
edited January 2015 in General questions
In iOS I have had this problem, in Android is fine. I use the latest version of Ads Interface, the problem is when no Internet connection and seems trying to connect in every frame. Is working with a very stuck performance. When he returns internet also seems to be trying to connect in every frame and slows.

I have read this thread but is a little older:
http://giderosmobile.com/forum/discussion/5029/ads-interface-issue-problem-when-no-internet-connection/p1

What is the solution for this problem?Also works for ios8?
@ar2rsawseen, you know anything about this please?

Thanks

Comments

  • The one in https://github.com/gideros/giderosplugins/tree/master/Ads/source/IOS/Plugins/Ads

    have Reachability included, which checks if there is internet connection before initiating ads, so it should have been solved. Unfortunately don't have ios8 to test it there
  • thanks @ar2rsawseen, this is automatic or need to add some code? ... Are checks only at the beginning or you can check the connection between levels?
  • tkhnomantkhnoman Member
    edited January 2015
    It works on iOS8, and 8.1.
    Automatic.
    If you run it on XCode, you can see "reachability bla-bla-bla" at the log. That is when it fired.

    I think i have a problem like that before. I just reset the device to solve the problem. I'm not sure why.
  • I tried to iOS8 without internet and the game freezes.

    Without Ads the game is fine but when he returns internet also seems to be trying to connect in every frame and slows.

    I just reset the device, but always returns to the same problem.
  • @yubaro do you see reachability blablabla at the nslog when running an app?
  • yubaroyubaro Member
    edited January 2015
    @ar2rsawseen,

    Without internet, infinite repeat:

    2015-01-27 14:20:46.934 appname[3086:607] Reachability Flag Status: -R tc----- networkStatusForFlags
    [gideros] starting render thread.
    2015/01/27 14:20:54 ad request failed: network is not available
    2015/01/27 14:20:54 ad request failed: network is not available
    2015/01/27 14:20:54 ad request failed: network is not available
    2015/01/27 14:20:54 ad request failed: network is not available
    ...

    With internet y later disabling internet, the game is slows or crash, i see this infinite repeat:

    2015-01-27 14:10:38.451 appname[2941:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    2015-01-27 14:10:38.451 appname[2941:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    2015-01-27 14:10:38.451 appname[2941:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    ....

    With internet, passing between levels or returning to home screen, the game is very slows, i see this infinite repeat:

    2015-01-27 15:01:45.039 appname[3389:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    2015-01-27 15:01:45.039 appname[3389:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    2015-01-27 15:01:45.039 appname[3389:607] Reachability Flag Status: -R -----l- networkStatusForFlags
    ...
  • tkhnomantkhnoman Member
    edited January 2015
    I checked. Mine didn't go that way.

    What Ads network did you use?
    (Admob/Chartboost/RevMob/others)

    Did you call adshow on event ad failed?
  • yubaroyubaro Member
    edited January 2015
    I use for my tests: Admob, iAd and Chartboost

    I use this code to make calls on event ad failed:
    admob:showAd("interstitial")  
    -- In case of banner 
    -- admob:show("auto")
     
    admob:addEventListener(Event.AD_FAILED, function(e)
    	iad:showAd("interstitial")
             -- In case of banner 
             -- iad:show("banner")
    	iad:addEventListener(Event.AD_FAILED, function(e)
    		  chartboost:showAd("interstitial")
    		end)
    	end)
    When not use chartboost:
    admob:showAd("interstitial")  
    -- In case of banner 
    -- admob:show("auto")
     
    admob:addEventListener(Event.AD_FAILED, function(e)
    	iad:showAd("interstitial")
             -- In case of banner 
             -- iad:show("banner")
    	end)
  • tkhnomantkhnoman Member
    edited January 2015
    Just to make sure, did you use both interstitial and banner together?
    It would be better to give :
    if e.type == "interstitial" then
    else
    end
    Probably, there is something wrong with your code (i can't make sure with just this one)
    So just try remove every Event.Ad_xxxx, and call showAd.
    If the problem goes away, then there must be a loop around your code.

    Edit: oh boy, and now i realized.
    Did you really add Event listener inside add Event listener like that?
    add Event Listener should be written on initialize/preparation once, and not after the function call.
  • yubaroyubaro Member
    edited January 2015
    @tkhnoman thanks for your answer, I use interstitial and banner separately.

    This code works perfectly on Android. In iOS fail.

    I've tried adding Event Listener on initialize and does not solve the problem. I use scene manager and the problem occurs in the pause button or by passing between scenes.
  • SinisterSoftSinisterSoft Maintainer
    edited January 2015
    @yubaro I do something similar to what you do, no crash. Here is my code:
    if chartboostId or amazonId or applovinId or adMobAppId or iadId then
    	require "ads"
     
    	if applovinId then
    		applovin=Ads.new("applovin")
    		if applovin then
     
    			applovin:setKey(applovinId)
     
    			applovin:addEventListener(Event.AD_FAILED,function(e)
    				print("applovin AD_FAILED",e.error)
    				if admob then
    					admob:showAd(adType,adMobUnitId)
    				end
    			end)
     
    			applovin:addEventListener(Event.AD_ERROR,function(e)
    				print("applovin AD_ERROR",e.error)
    			end)
     
    			applovin:addEventListener(Event.AD_RECEIVED,function(e)
    				print("applovin AD_RECEIVED")
    			end)
     
    			applovin:addEventListener(Event.AD_DISPLAYED,function(e)
    				print("applovin AD_DISPLAYED")
    			end)
     
    			applovin:addEventListener(Event.AD_ACTION_BEGIN,function(e)
    				print("applovin AD_ACTION_BEGIN")
    			end)
     
    			applovin:addEventListener(Event.AD_ACTION_END,function(e)
    				print("applovin AD_ACTION_END")
    			end)
     
    			applovin:addEventListener(Event.AD_DISMISSED,function(e)
    				print("applovin AD_DISMISSED")
    			end)
     
    		end
    	end
     
    	if adMobAppId then
    		admob=Ads.new("admob")
    		if admob then
     
    			admob:setKey(adMobAppId)
     
    			admob:addEventListener(Event.AD_FAILED,function(e)
    				print("admob AD_FAILED",e.error)
    			end)
     
    			admob:addEventListener(Event.AD_ERROR,function(e)
    				print("admob AD_ERROR",e.error)
    			end)
     
    			admob:addEventListener(Event.AD_RECEIVED,function(e)
    				print("admob AD_RECEIVED")
    			end)
     
    			admob:addEventListener(Event.AD_DISPLAYED,function(e)
    				print("admob AD_DISPLAYED")
    			end)
     
    			admob:addEventListener(Event.AD_ACTION_BEGIN,function(e)
    				print("admob AD_ACTION_BEGIN")
    			end)
     
    			admob:addEventListener(Event.AD_ACTION_END,function(e)
    				print("admob AD_ACTION_END")
    			end)
     
    			admob:addEventListener(Event.AD_DISMISSED,function(e)
    				print("admob AD_DISMISSED")
    			end)
    		end
    	end
     
    	if amazonId then
    		amazon=Ads.new("amazon")
    		if amazon then
     
    			amazon:setKey(amazonId)
     
    			amazon:addEventListener(Event.AD_FAILED,function(e)
    				print("amazon AD_FAILED",e.error)
    				if chartboost then
    					chartboost:showAd(adType)
    				elseif applovin then
    					applovin:showAd(adType)
    				elseif admob then
    					admob:showAd(adType,adMobUnitId)
    				end
    			end)
     
    			amazon:addEventListener(Event.AD_ERROR,function(e)
    				print("amazon AD_ERROR",e.error)
    			end)
     
    			amazon:addEventListener(Event.AD_RECEIVED,function(e)
    				print("amazon AD_RECEIVED")
    			end)
     
    			amazon:addEventListener(Event.AD_DISPLAYED,function(e)
    				print("amazon AD_DISPLAYED")
    			end)
     
    			amazon:addEventListener(Event.AD_ACTION_BEGIN,function(e)
    				print("amazon AD_ACTION_BEGIN")
    			end)
     
    			amazon:addEventListener(Event.AD_ACTION_END,function(e)
    				print("amazon AD_ACTION_END")
    			end)
     
    			amazon:addEventListener(Event.AD_DISMISSED,function(e)
    				print("amazon AD_DISMISSED")
    			end)
    		end
    	end
     
    	if iadId then
    		iad=Ads.new("iad")
    		if iad then
     
    			iad:addEventListener(Event.AD_FAILED,function(e)
    				print("iad AD_FAILED",e.error)
    				if chartboost then
    					chartboost:showAd(adType)
    				elseif applovin then
    					applovin:showAd(adType)
    				elseif admob then
    					admob:showAd(adType,adMobUnitId)
    				end
    			end)
     
    			iad:addEventListener(Event.AD_ERROR,function(e)
    				print("iad AD_ERROR",e.error)
    			end)
     
    			iad:addEventListener(Event.AD_RECEIVED,function(e)
    				print("iad AD_RECEIVED")
    			end)
     
    			iad:addEventListener(Event.AD_DISPLAYED,function(e)
    				print("iad AD_DISPLAYED")
    			end)
     
    			iad:addEventListener(Event.AD_ACTION_BEGIN,function(e)
    				print("iad AD_ACTION_BEGIN")
    			end)
     
    			iad:addEventListener(Event.AD_ACTION_END,function(e)
    				print("iad AD_ACTION_END")
    			end)
     
    			iad:addEventListener(Event.AD_DISMISSED,function(e)
    				print("iad AD_DISMISSED")
    			end)
    		end
    	end
     
    	chartboost=Ads.new("chartboost")
    	if chartboost then
     
    		chartboost:setKey(chartboostId,chartboostSig)
     
    		chartboost:addEventListener(Event.AD_FAILED,function(e)
    			print("chartboost AD_FAILED",e.error)
    			if applovin then
    				applovin:showAd(adType)
    			elseif admob then
    				admob:showAd(adType,adMobUnitId)
    			end
    		end)
     
    		chartboost:addEventListener(Event.AD_ERROR,function(e)
    			print("chartboost AD_ERROR",e.error)
    		end)
     
    		chartboost:addEventListener(Event.AD_RECEIVED,function(e)
    			print("chartboost AD_RECEIVED")
    		end)
     
    		chartboost:addEventListener(Event.AD_DISPLAYED,function(e)
    			print("chartboost AD_DISPLAYED")
    		end)
     
    		chartboost:addEventListener(Event.AD_ACTION_BEGIN,function(e)
    			print("chartboost AD_ACTION_BEGIN")
    		end)
     
    		chartboost:addEventListener(Event.AD_ACTION_END,function(e)
    			print("chartboost AD_ACTION_END")
    		end)
     
    		chartboost:addEventListener(Event.AD_DISMISSED,function(e)
    			print("chartboost AD_DISMISSED")
    		end)
     
    	end
     
    end
     
    function tryAdvert()
    	if not premium then
    		print("*** ADVERT ***")
    		if amazon then
    			amazon:showAd(adType)
    		elseif iad then
    			iad:showAd(adType)
    		elseif chartboost then
    			chartboost:showAd(adType)
    		elseif applovin then
    			applovin:showAd(adType)
    		elseif admob then
    			admob:showAd(adType,adMobUnitId)
    		end
    	end
    end
    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
  • yubaroyubaro Member
    edited January 2015
    @SinisterSoft thanks for you answer.

    Here there is no code when it fails. Any reason?

    admob:addEventListener(Event.AD_FAILED,function(e)
    print("admob AD_FAILED",e.error)
    end)

    You use it for both interstitial and banner? Or separately?

    Maybe separately:
    function tryAdvertBanner() and function tryAdvertInterstitial()

    Thanks again!
  • SinisterSoftSinisterSoft Maintainer
    edited January 2015
    I don't use banners - on admob and applovin I disable them.

    Nobody likes them, I doubt if they ever get clicked.
    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
  • yubaroyubaro Member
    edited January 2015
    @SinisterSoft, How do you define the iadId variable?
  • SinisterSoftSinisterSoft Maintainer
    edited January 2015
    I just set it to true if on iOS.

    I have this at the beginnning of my code:
    if device[1]=="Windows" or device[1]=="Mac OS" then
    	pc=true
    elseif device[1]=="Android" then
    	android=true
    	if device[3]=="Amazon" then
    		kindle=true
    	elseif device[3]=="OUYA" then
    		ouya=true
    --	elseif device[3]=="Geniatech" then
    --		gamestick=true
    	end
    elseif device[1]=="iOS" then
    	ios=true
    end
    then in a 'custom.lua' file that is 'required' by the main source (I exclude it in the project'.

    I also set up other skinning parameters in this file, depending on the game, eg - a Christmas game, an Easter game - they would use the same engine (main.lua) but different custom.lua files and graphics.
    androidRater="<a href="https://play.google.com/store/apps/details?id=com" rel="nofollow">https://play.google.com/store/apps/details?id=com</a>. - rest of game id here"
    iosRater="<a href="https://itunes.apple.com/app/id" rel="nofollow">https://itunes.apple.com/app/id</a> - itunes game id here" 
    facebookAppId=" facebook app id here"
     
    if android then
    	flurryId="flurry android id here "
    	if kindle then
    		chartboostId=" chartboost amazon id here "
    		chartboostSig=" chartboost amazon sig id here "
    		amazonId=" amazon app id here "
    		androidRater="<a href="http://www.amazon.com/gp/mas/dl/android?p=com" rel="nofollow">http://www.amazon.com/gp/mas/dl/android?p=com</a>. - rest of game id here "
    	elseif ouya then
    		androidRater=nil
    	else
    		chartboostId=" chartboost android id here "
    		chartboostSig=" chartboost android sig id here "
    		applovinId=" android app lovin id "
    		adMobAppId=" admob android app id here "
    		adMobUnitId="ca-app-pub- rest of android unit id here"
    	end
    elseif ios then
    	flurryId=" flurry ios id here"
    	iadId=true
    	chartboostId="chartboost ios id here "
    	chartboostSig=" chartboost ios sig id here"
    	applovinId=" applovin ios id here"
    	adMobAppId=" admob ios ipp id here"
    	adMobUnitId="ca-app-pub- rest of ios unit id here"
    end
    If the id is not defined then the advert will not appear and the whole thing falls back to less ad suppliers (or none at all in the case of PC).
    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
  • yubaroyubaro Member
    edited January 2015
    @SinisterSoft many thanks...one question, I know that adMobUnitId="ca-app-pub-ca-XXXXXXXXXXXXXXXX/YYYYYYYYYY", but adMobAppId?
  • If you go to admob and look at an app in your settings you will see the id in the url.
    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
  • Well you can either set it "globally" using setKey
    or provide separately for each ad, as this key is actually ad dependent (meaning would be different for banner and interstitial)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • @ar2rsawseen, oh yes, thanks for your explanation
  • I juust like to keep it all in one place, set it all up and they just call tryAd (or whatever) when I want to show an advert and leave it to just work on its own.
    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
Sign In or Register to comment.