Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone SDK detect Wifi and Carrier network

my app accesses the internet and i just want to detect whether there is a connection either via wifi or via carrier data network or not

apple has made an example for that "Reachability"

https://developer.apple.com/iphone/library/samplecode/Reachability/

i think it just detects the wifi and not the carrier network

can anyone tell me, whats the best to be done to detect if there's a connection ( any type of connection )

Appreciate ur help!

like image 946
Mina Mikhael Avatar asked Oct 26 '09 14:10

Mina Mikhael


People also ask

How do I check my network on iOS?

To check if your iOS mobile device is connected to Wi-Fi:From the main screen of your device, look for and open Settings. With Settings open, look for the Wi-Fi field. Off - the Wi-Fi antenna is currently disabled. Not Connected - Wi-Fi is turned on, but your device is not currently connected to a network.

Why is my iPhone not connecting to the network?

Reset your Network Settings Go to Settings > General > Transfer or Reset [Device] > Reset > Reset Network Settings. This also resets Wi-Fi networks and passwords, cellular settings, and VPN and APN settings that you've used before.

How do I know if my Internet connection is swift?

Using Reachability. swift. In the viewWillAppear method, add an observer to the Notification Center, so every time the network state changes, like from Wifi goes to Cellular, this will be detected instantly and call the reachabilityChanged method.

How to change network on Apple iPhone?

Touch Cellular. Touch Cellular Data Options. Touch Cellular Data Options. Touch Enable 4G to use the 4G network.


2 Answers

That sample is exactly what you need.

Look at Reachability.m. it'll tell you whether you have any connection, and then tell you what kind of connection you have.

like image 159
Oren Mazor Avatar answered Sep 28 '22 14:09

Oren Mazor


The Reachability example may be overkill if you just want to detect whether or not you are connected, and what type of connection you are using if you are connected. Indeed the example also contains code showing how to setup and use callbacks that notify you of state changes.

For a snippet of source code telling you exactly if you are connected or not, and what type of connection you are using, you may want to take a look at my answer to a similar question, posted here.

like image 29
Massimo Cafaro Avatar answered Sep 28 '22 13:09

Massimo Cafaro