How to detect if the device Internet connection is Wifi or 3G?

Is there a way to detect if the Internet connection of the underlying device is based on Wifi or 3G?

For example, the app wants to know if the device Internet connection is Wifi or 3G, then it can decide if some features are available (3G is too slow for some features).

Hi,

If you have access to a web server you can create a php file on then you can use the method I created for an app.

Scroll down to the entry from gazjm on this link

http://forums.coronalabs.com/topic/15731-handy-code-snippets

Thanks for sharing. I actually have a server that can do similar thing by evaluating the RTT (round-trip time). 

However, I am also wondering if CoronaSDK can detect if the Internet connection is Wifi or 3G on a lower-level sense?

As far as I know it can only tell if you have an internet connection, not the type of connection.

There is an undocumented method that you can use : network.getConnectionStatus()

Look in this thread for more information : http://forums.coronalabs.com/topic/32644-any-tips-to-get-network-status/

@nmichaud

cool, it’s exactly what I am looking for.

local status = network.getConnectionStatus() if status.isConnected then -- Device is currently connected to a network. end if status.isMobile then -- Device has network access via cellular service. else -- Device has network access via WiFi. end

But for the case “isMobile == true”, does it mean 3G and 4G as well?  

For iOS you can use the network reachability API’s:     http://docs.coronalabs.com/api/event/networkStatus/index.html

Rob

Hi,

If you have access to a web server you can create a php file on then you can use the method I created for an app.

Scroll down to the entry from gazjm on this link

http://forums.coronalabs.com/topic/15731-handy-code-snippets

Thanks for sharing. I actually have a server that can do similar thing by evaluating the RTT (round-trip time). 

However, I am also wondering if CoronaSDK can detect if the Internet connection is Wifi or 3G on a lower-level sense?

As far as I know it can only tell if you have an internet connection, not the type of connection.

There is an undocumented method that you can use : network.getConnectionStatus()

Look in this thread for more information : http://forums.coronalabs.com/topic/32644-any-tips-to-get-network-status/

@nmichaud

cool, it’s exactly what I am looking for.

local status = network.getConnectionStatus() if status.isConnected then -- Device is currently connected to a network. end if status.isMobile then -- Device has network access via cellular service. else -- Device has network access via WiFi. end

But for the case “isMobile == true”, does it mean 3G and 4G as well?  

For iOS you can use the network reachability API’s:     http://docs.coronalabs.com/api/event/networkStatus/index.html

Rob