Due to internet connection unavailability google ads crashes app.

I am very new to Corona SDK. My app works perfectly with google admob and vungle ads when internet is available. But it crashes when tries to load ads in absence of internet. Please can anyone suggest me what can I do.

On iOS there are a set of API calls and events that let you monitor and react to network status changes.  See:  http://docs.coronalabs.com/api/event/networkStatus/index.html

These are available on Android, and the best thing you can do is try and open a socket connection to a service that should always be up like google.com with a short time out and if that fails, turn off your network activities.

local socket = require("socket") local http = require("socket.http")   function testNetworkConnection()     print("testing connection")     if http.request( "http://google.com" ) == nil then         print("cant connect to google")         return false     end     print("got a connection")     return true end

Its probably best to call this near a network operation, though the time out may be in the 1 second range which can be an eternity.

Rob

I use google and vungle ads and I’ve never had a single issue with apps crushing due to no internet connection. If the user has no connection the ads simply don’t show. In fact I use airplane mode all the time to prevent the ads from showing so I can take screenshots of the app.

On iOS there are a set of API calls and events that let you monitor and react to network status changes.  See:  http://docs.coronalabs.com/api/event/networkStatus/index.html

These are available on Android, and the best thing you can do is try and open a socket connection to a service that should always be up like google.com with a short time out and if that fails, turn off your network activities.

local socket = require("socket") local http = require("socket.http")   function testNetworkConnection()     print("testing connection")     if http.request( "http://google.com" ) == nil then         print("cant connect to google")         return false     end     print("got a connection")     return true end

Its probably best to call this near a network operation, though the time out may be in the 1 second range which can be an eternity.

Rob

I use google and vungle ads and I’ve never had a single issue with apps crushing due to no internet connection. If the user has no connection the ads simply don’t show. In fact I use airplane mode all the time to prevent the ads from showing so I can take screenshots of the app.