How to test if you're on Wifi or cellular data (mobile)

I’ve seen lots of questions covering general network reachability, but I need to determine what type of connection to the network I have: wifi or cellular. Is there a way to distinguish this?

(Application.internetReachability doesn’t do this.)

The short answer:

It’s not possible to know 100% on which network the device is currently loading its data.


NetworkReachability.ReachableViaCarrierDataNetwork as suggested by some will not work as intended because it doesn’t detect if the device’s mobile data is active, but just that the device has access to the mobile data via a SIM card. There are devices where it will return false when the mobile data is turned off, but it’s not universal as it’s related to how the manufacturer made the device. For example, it might return false if the mobile data is disabled, but might return true if the Bluetooth is enabled because the Bluetooth might (in most cases) uses the same antenna receiver as the mobile data. If the manufacturer invested in dual-antenna (or more) receiver and properly implemented the drivers so that the OS knows which system is active AND can completely turn off one of the antenna receiver, it’s possible for the OS to purposely know that the SIM card is not accessible (when the Mobile Data is turned off). To be honest, it’s not the kind of randomness you want to tackle with at any point.


To give an example, a Chromebook or an Android TV without a SIM card will return false to NetworkReachability.ReachableViaCarrierDataNetwork, but will return true to NetworkReachability.ReachableViaLocalAreaNetwork and that is even if its WIFI access is turned off. NetworkReachability.NotReachable is supposed to only be true if the device has neither access to WIFI nor a Carrier SIM card. This is, nowadays, a rare occurrence, but can be found in devices which only allow app to be installed only via USB.


Now, why is it that it’s impossible for an App to know if the device is on mobile or wifi?

It’s a security measure set by the makers of the various OS. The Internet access of a device is managed by multiple modules/drivers/software and even parts. You’re not just connected by having a magical signal with a satellite or a Router. Having even just partial information about the device’s network access opens the risks of data exchange to be compromised.

Hey @vargonian, this should be possible through NetworkReachability.ReachableViaCarrierDataNetwork