0
\$\begingroup\$

How can you detect someone's Internet connection in Unity? I see a lot of forums where people make a request to any site (mostly google.com) to check it, but it does not seem to be an elegant solution.

With 3G/4G connections to serve Unity ads or admob interstitial, it takes a lot of time and crashes the game.

Regards!

\$\endgroup\$
1
  • \$\begingroup\$ I've created an Android's library that can be used as Unity's plugin for this purpose. If anyone's interested it's available under github.com/rixment/awu-plugin Hope it helps, cheers! \$\endgroup\$
    – user136825
    Commented Mar 17, 2020 at 19:12

1 Answer 1

1
\$\begingroup\$

Unity or not, the principle is always the same: Do a (http) request to a well known server (or a few alternative ones) and conclude that "there is internet connection" only as the reply is safely back home and well grabbed.

The term "internet connection" can be interpreteted in different ways, but it always comes down to that "almost internet connection" or "should be internet connection" is worthless/irrelevant and hence equal to "no internet connection". For example, it's worthless to know that the OS claims a connection is "up" - the connection must also be functional, and tested for that. It is also worthless to know that there is connection up to for example the 3rd hop, if that that hop still happens to reside in local, nearby infrastructure.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .