- Home /
Check if the device has internet connection
Hello everyone,
i need to check if the game is connected to internet or not, the game is for mobile, so the present of a network carrier provide a problem... i tried ping.isDone, it works perfectly on pc but on mobile it always return true.
any help please ?
Answer by tonic · Jun 28, 2014 at 06:20 AM
I just released an asset like that (does what SkaredCreations described). It uses simple technique called "captive portal detection" used by Microsoft, Google and Apple (and in fact offers possibility to use their way, or either your own custom hosted one).
The connection check has to be done with that technique to truly know you're online, and not just e.g. hitting a public WiFi login page. (So, just checking Application.internetReachability or doing a Ping to some address doesn't guarantee you can successfully make connections or make WWW requests.)
My asset is called Internet Reachability Verifier. More info here: http://j.mp/IRVUN
Answer by SkaredCreations · Mar 22, 2014 at 03:12 AM
You could use a workaround like create a coroutine where you try to access www.google.com with the built-in WWW class (this is not ideal because even if it's BigG, sometimes it may happen that its website is not reachable, but you know, it's Google so it happens very rarely), in this coroutine you could even keep trying to access until it succeeds (for example if the user enables Wifi/carrier connection after your game has started).
Your answer
Follow this Question
Related Questions
Ping make my android app crash if no internet connection 1 Answer
How do I Force Application to Quit if no internet connection available 1 Answer
Little "No Internet" dialog 2 Answers
how to on and off wifi settings through app in unity 5.3.4 0 Answers
Android game: allow internet for just specific domain 0 Answers