How to check that I can get ads and network is ok?

Hi
I intent to prevent my free game from running when no ads can be shown if the wifi/Cellular connection is disabled.

Does the isReady() function return false also when no ads are available for that zone even though the connection to the server might be ok?

If so how can I check that the connection to the ads server is up and that ads can be shown? I only want to catch the case where the connection is lost (wifi off for example) and not the cases where there are no ads available (not advertisers) anymore.

Thanks

In order to provide additional feedback from the other forums,
many who want to test connectivity resort to ping the server
like @Johannski code in

In addition to the above question (please unity can you comment on that),
If I want to follow the solution of the above link is there a UnityAds server address that i can ping to verify that network connectivity is ok and ads can be served?

Thanks

I can’t answer your first question, but to my ping test. I guess, it is enough to check just one ping in order to tell whether there is an internet connection, because in case of a problem with the ads server, the user shouldn’t be punished. You could for example ping “8.8.8.8”, which is the Google DNS server, you won’t have stability problems with this one.

Doing a ping test is also a very cheap thing to do, and it won’t cost much time to get a response, so you could do it every 30 seconds, or before you start a new round of a game (Don’t know what kind of game you have), just to make sure, that the user doesn’t try to get rid of the Ads, by turning of wifi, after he/she started the game.

1 Like

Yes, even when a connection is established, if no ads are available, the isReady() method will return false.

Unity’s scripting API provides you with the ability to test internetReachability, which reports that the network is either ReachableViaCarrierDataNetwork, ReachableViaLocalAreaNetwork, or NotReachable.

I haven’t yet tested the internetReachability property in various edge cases that can sometimes cause a false positive, such as being connected to a router with no connection to the internet. Pinging a reliable server in this case could be a more reliable test for network connectivity. It’s worth exploring the edge.

I havent thought about using the google dns server, but i think your point is valid, why punish the user when the ads server has problems.

There have been also other related threads, which try to use a www/Get query from a dummy web page.

Or combining the ping with the internetReachability flag
http://stackoverflow.com/questions/24351155/unity-check-internet-connection-availability

I will try the ping method and let you know how it worked.

Thanks for your replies.

1 Like

I have a problem

I have a problem related to this.I had integrated unity ads in my game.The problem is that whenever there is Internet connection available then the ads start and after sometime the game also starts but when the net connection is nlt available then the game gets stuck on the loading screen.Any pointers.Thanks.