AdMob is crashing without internet connection.

It seems that AdMob is crashing when it does not have internet connection.

I have reported bug #34214, but I hope that someone can confirm that its not just me before developers will get to it.

here is code to reproduce

local Admob = { &nbsp; &nbsp; BannerID = "", &nbsp; &nbsp; FullscreenID = "", &nbsp; &nbsp; Handle = nil }; function Admob.Initialize() &nbsp; &nbsp; Admob.BannerID = "\<some id here\>"; &nbsp; &nbsp; Admob.FullscreenID = "\<other id here\>"; &nbsp; &nbsp; Admob.Handle = require("ads"); &nbsp; &nbsp; Admob.Handle.init("admob", Admob.FullscreenID, function(e) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end); &nbsp;&nbsp; end function Admob.ShowBanner() &nbsp; &nbsp; Admob.Handle:setCurrentProvider("admob"); &nbsp; &nbsp; Admob.Handle.hide(); &nbsp; &nbsp; Admob.Handle.show("banner", { &nbsp; &nbsp; &nbsp; &nbsp; x = display.screenOriginX, &nbsp; &nbsp; &nbsp; &nbsp; y = 9999, &nbsp; &nbsp; &nbsp; &nbsp; appId = Admob.BannerID &nbsp; &nbsp; }); end function Admob.ShowFullscreen() &nbsp; &nbsp; Admob.Handle:setCurrentProvider("admob"); &nbsp; &nbsp; Admob.Handle.hide(); &nbsp; &nbsp; Admob.Handle.show("interstitial", { &nbsp; &nbsp; &nbsp; &nbsp; appId = Admob.FullscreenID &nbsp; &nbsp; }); end function Admob.Hide() &nbsp; &nbsp; if (Admob.Handle) then &nbsp; &nbsp; &nbsp; &nbsp; Admob.Handle:setCurrentProvider("admob"); &nbsp; &nbsp; &nbsp; &nbsp; Admob.Handle.hide(); &nbsp; &nbsp; end end Admob.Initialize(); Admob.ShowBanner(); timer.performWithDelay(1000, Admob.ShowFullscreen);

On my computer it crashes when trying on ios simulator. Just turn off wifi before opening it.

It also crashes on my iphone with airplane mode on.

Use Admob v2 plugin

Thank you

You need to make a function that checks your internet connection before you show an interstitial ad.  Otherwise the app will crash in iOS in airplane mode.

e.g.  I use this in my apps (found this on the web):

local socket = require("socket")&nbsp; function checkConnection() local connection = socket.tcp() connection:settimeout(1000) local result = connection:connect("www.google.com", 80) connection:close() if result then return true else return false end end

dislam,

Thank you. I already submitted my game with patch similar to yours, but I think this bug should be fixed anyway

Yes - this happens to me also. 

I’ll just chip in here - something i thought about while reading the post.

Is it possible to check if device is in airplane mode rather than the internet connection?

T.

You need to make a function that checks your internet connection before you show an interstitial ad.  Otherwise the app will crash in iOS in airplane mode.

e.g.  I use this in my apps (found this on the web):

local socket = require("socket")&nbsp; function checkConnection() local connection = socket.tcp() connection:settimeout(1000) local result = connection:connect("www.google.com", 80) connection:close() if result then return true else return false end end

dislam,

Thank you. I already submitted my game with patch similar to yours, but I think this bug should be fixed anyway

Yes - this happens to me also. 

I’ll just chip in here - something i thought about while reading the post.

Is it possible to check if device is in airplane mode rather than the internet connection?

T.