iphone SDK detect Wifi and Carrier network

24,174

Solution 1

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.

Solution 2

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.

Solution 3

Once you make a request to any web resource, the iPhone uses any connection it finds, it uses wifi ( as a higher priority ), and if wifi is not connected it uses carrier network. There's no code settings thats preventing carrier network.

All you have to do:

  • Check the signal at the testing place.
  • Check the link you are trying to reach on safari, to make sure its not your app that have the problem.
  • Contact your carrier support if the link is not working on safari ( for sure using the carrier network )

Solution 4

These techniques are useful, but keep in mind that the device's path to the Internet might consist of several different types of connections. For example, a iPhone or iPod touch might be using WiFi to connect to a mobile hotspot, which in turn has its own 3G wireless connection. So it is not safe to assume that the presence of a WiFi connection implies higher bandwidth than 3G.

Share:
24,174
Mina Mikhael
Author by

Mina Mikhael

10 years’ experience and a real passion for mobile application development. Readily embracing cutting-edge technology, I have gained an in-depth understanding of the main mobile platforms and recognize the subtle differences between each. Having helped develop a series of commercially successful apps on iOS.

Updated on November 21, 2020

Comments

  • Mina Mikhael
    Mina Mikhael over 3 years

    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!

  • Tim
    Tim over 14 years
    To address your question more specifically: the Reachability code will detect any kind of connection, not just WiFi. All you have to do is import the Reachability classes into your project, then instantiate a Reachability object and go from there.