Plugin crashes when offline

Hi everyone,

I think I’ve just discovered a bug in the Chartboost plugin. When I try to initialize the plugin, it crashes the game when the device is not connected to the internet.

iOS -> App is closed immediately

Android -> Black screen

It’s a shame that it won’t be updated anymore so, any workaround for this situation?

Thank you in advance.

Anyone?

You need to test the network and see if it’s there before you call any plugin or network code that you need.  On iOS we support a full suite of options to test network connectivity.  See:  https://docs.coronalabs.com/api/event/networkStatus/index.html

But on other platforms, you basically have to do it the old-fashioned way and try connecting to a server somewhere and see if you get a connection or not.

local socket = require("socket") local http = require("socket.http") local ltn12 = require("ltn12") 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

You can connect to your own server or any server that should be up. It should connect pretty quickly. If it can’t connect it should time out in a second or so…

Rob

I hoped that I wouldn’t have to do that since other plugins (AdMob, Vungle etc.) does that check for us. I guess there is no other way to do it than to check for network connection.

Thank you Rob.

Update:

Sorry for my lack of testing. I thought it was Vungle but after a couple more tests, I found out that the reason was Chartboost plugin. Can you move this topic to Chartboost forum?

I have edited the first post to reflect that.

Moved

Anyone?

You need to test the network and see if it’s there before you call any plugin or network code that you need.  On iOS we support a full suite of options to test network connectivity.  See:  https://docs.coronalabs.com/api/event/networkStatus/index.html

But on other platforms, you basically have to do it the old-fashioned way and try connecting to a server somewhere and see if you get a connection or not.

local socket = require("socket") local http = require("socket.http") local ltn12 = require("ltn12") 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

You can connect to your own server or any server that should be up. It should connect pretty quickly. If it can’t connect it should time out in a second or so…

Rob

I hoped that I wouldn’t have to do that since other plugins (AdMob, Vungle etc.) does that check for us. I guess there is no other way to do it than to check for network connection.

Thank you Rob.

Update:

Sorry for my lack of testing. I thought it was Vungle but after a couple more tests, I found out that the reason was Chartboost plugin. Can you move this topic to Chartboost forum?

I have edited the first post to reflect that.

Moved