Apple Internet Reachability fails to work - iphone

I have tested a reachability code provided by apple but it fails in following scenerio. Same is tested by AFNetworking library 2.0, and it also fails:
1). Turn on wifi and Run code.
2). Turn off you your data connection just by unplugging your cable from device, but keep in mind you have a wifi signal on your iphone device.
3). Now run code and it will say internet unavailable.
4). Now connect cable again in wifi device.
Now run your code again and it will says that your network is unavailable, although you can check safari is safely browsing.
You have to restart your iphone again to have a normal codition.
Note: it fails only when you check with this scenerio. it works fine with cellular network.
What can i do ? is it an apple bug ?

Related

iPhone simulator - simulate 3G connection

I am testing the Reachability api, but my physical device only has WiFi access, as I don't have a phone contract. My code needs to distinguish between being connected to 3G/2G or WiFi. Is it possible to simulate a 3G connection on the iPhone simulator?
Clarifications: I am using Snow Leopard. Limiting the bandwidth is not what I need. I need for the actual interface to be identified as the 3G or 2G radio, as opposed to WiFi.
If you are using Lion try the Network Link Conditioner
Nowdays there is a part in Preferences on the device (when registered as a developer device) where a "Network Link Conditioner" is available.
You might also like Speed Limit.
Edit: I'm not sure if this will work as an identifier for 3g though. I'll update my answer after I do some tests (I'm working on exactly the same thing right now!)
I dont think that it is a build-in-functionality in iphone-simulator. But I test it sometimes on my device with wifi (and 3g) disabled.
If you dont have an iPhone but sth. similar (Android for instance) then just enable tethering on your device and use the tethered internet-connection. Then your iPhone-Simulator only gets slow speed ;)
edit: another idea is to limit the bandwidth of your mac. I found this tool online (have not tested it) which should be able to limit network-traffic (to your local router/modem)

Why iphone Bluetooth chat application working without activating bluetooth or wifi?

I have created iphone bluetooth chat application using following tutorial:http://www.devx.com/wireless/Article/43502/1954.
It works well.But when i turn off wifi and bluetooth both in my pc and test with
iphone simulator with another pc which has also turned off its bluetooth and wifi.
It still works fine and both peer discovers each other.both pcs are conneted through LAN.
Can anyone tell why this happens?
I guess the simulator just performs discovery using any available network connection. I very much doubt that the simulator was using the Bluetooth of your PC for peer discovery.
As you say, "Both PCs are connected through LAN". Well, I guess that is your answer. Discovery is being done via LAN.
If you want to test actual bluetooth usage scenarios, I guess you have to use an actual device.

Reachability App 2.2 - Local Wifi does not restore

Can somebody explain why the reachability app behaves strangely?
I built it under IOS 4.2
When I start it, all three text boxes show an available network.
If I turn the airport off, they all show no connection.
Turning the Airport back on again only Remote Host and TCP/IP routing are shown as availabl. Local Wifi remains 'Access not available'
This may seem like a dumb question, but did you build it in the simulator? Results on the simulator won't mirror those on the device, as the 3G in the simulator is simply an abstraction of the wifi radio in your Mac. You'll need to use a device in order to see it work.

Issue with the wifi in iPad

I am working on a educational related apps. My app functionality is working well when the WIFI is connected otherwise it is getting crashed.
In my app I am connecting with the server using NSURLRequest class its working.
the download also not having any problem if the wifi is available.
problem rectification: I have to know weather the my app device is connected with external network or not.
So, how can I know my app is connected with the wifi or not?
The following link consists source code, in which it consists how to check the reachability. That means the wifi or any network is connected of not.
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
Apple provides sample code called "Reachability" to detect when the network is available. That would be a good starting point, though a quick Google should locate some alternatives.

iPhone, NSData, wifi vs. cellular network

I'm working on an application that downloads some data from the internet using NSData's initWithContentsOfURL method. At startup I'm using some code from Apple's Reachability sample to check if a wifi connection is available; if not, then the app just shows an error message and refuses to really start (as requested by my client). All is working fine on iPod and iPad, but on iPhone, my client reports much, much slower download speeds, unless he turns on airplane mode, in which case download speeds are on par with iPod / iPad speeds. So it seems that even though a wifi connection is available, the iPhone is probably using the cellular network to download the data. Which is really weird. Does anyone have any idea about what I might be doing wrong?
I believe your answer is SCNetworkReachability which you already have access to since you are using Apple's Reachability code.
The SCNetworkReachability API allows an application to determine the status of a system's current network configuration and the reachability of a target host. One of the flags returned by the API, kSCNetworkReachabilityFlagsIsWWAN, will tell you if a network connection to the target host uses the carrier network. The Reachability sample code shows how to determine the active network connection.
You could also use this to enforce WiFi if that's what you want.
Have a look at UIRequiresPersistentWiFi