How does Application.internetReachability work and how fast is it?

I’m implementing some online features in my game and i want to check for internet connection before displaying something from the internet when a user clicks on a button.

i’m using:

if(Application.internetReachability != NetworkReachability.NotReachable)
{
    // Do stuff here
}
else
{
    // No internet connection
}

What Application.internetReachability actually does?
How fast is it*?*
Is it cached? or it is calculated every time i call it?
Should i use it inside of a Coroutine? or call it directly?

It might not do what you want at all.

As per the documentation Unity - Scripting API: Application.internetReachability :

I think you’re better off using something like a simple network request to your server to verify actual connectivity.

@PraetorBlue
If my game is only for mobile devices, can i use it to detect Internet connection?

I don’t think so. I think it will just tell you if you’re connected to Wifi or carrier network. There’s a possibility you are connected to Wifi but actually have no internet connectivity.

1 Like