I have a Windows Phone 8 app that is stable and has been out in the wild for quite some time now. A few users have reported odd behaviour that I cannot reproduce. However, the odd behaviour reported would make sense if these particular devices are reporting DeviceNetworkInformation.IsNetworkAvailable as true when in fact the app does not have access to online data.
Is DeviceNetworkInformation.IsNetworkAvailable reliable? Or perhaps I should be checking something else to reliably determine if the app has access to online data?
In my case two distinct pieces of functionality are affected - checking for the presence of product licences, and determining if the map control is online. Both checks use DeviceNetworkInformation.IsNetworkAvailable.
The user reported occurrences seem to be very rare, but persistent for the users affected.
DeviceNetworkInformation.IsNetworkAvailable will result in true if the user is connected to Wifi or has Mobile Data turned on. This does not guarantee that the Wifi is connecting phone to the internet. Or in case of Mobile Internet the phone could be connected to a 2G network which sometimes is not good enough to connect to a service or fetch large amount of data.
As a practice, use DeviceNetworkInformation.IsNetworkAvailable as a primary check for the access. But do not rely on it completely. Also register for DeviceNetworkInformation.NetworkAvailabilityChanged
event to check if the state of the network changes while your code is running.
For reference and more details check out this article