Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to detect if the device Internet connection is Wifi or 3G?
Started by joe528 Jan 19 2015 01:05 AM

- - - - -
6 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

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).



[TOPIC: post.html]
#2

gazjm

[GLOBAL: userInfoPane.html]
gazjm
  • Contributor

  • 159 posts
  • Corona SDK

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

[TOPIC: post.html]
#3

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

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?



[TOPIC: post.html]
#4

gazjm

[GLOBAL: userInfoPane.html]
gazjm
  • Contributor

  • 159 posts
  • Corona SDK

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



[TOPIC: post.html]
#5

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

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/



[TOPIC: post.html]
#6

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

@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?  



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,935 posts
  • Enterprise

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

 

Rob




[topic_controls]
[/topic_controls]