PDA

View Full Version : Detect network type change automatically.




imho
Nov 10, 2008, 06:57 PM
Is it possible to detect network type switching (e.g WIFI to 3G) automatically with say a callback or something?

I checked the Reachability sample, it doesn't really do that at all. The only other way i could think of is to constantly poll the network type which i'm sure is a pretty dumb and inefficient solution.

Thanks.



robbieduncan
Nov 11, 2008, 03:17 AM
I checked the Reachability sample, it doesn't really do that at all. The only other way i could think of is to constantly poll the network type which i'm sure is a pretty dumb and inefficient solution.

Really? I thought it did. I'm not on a Mac to check right now...

jnic
Nov 11, 2008, 07:09 AM
Really? I thought it did. I'm not on a Mac to check right now...

It does, here's a link to the Readme: http://developer.apple.com/iphone/library/samplecode/Reachability/listing6.html.

"ReachableViaWiFiNetwork" and "ReachableViaCarrierDataNetwork" tell you whether you're running over Wifi or 3G respectively.

robbieduncan
Nov 11, 2008, 07:12 AM
It does, here's a link to the Readme: http://developer.apple.com/iphone/library/samplecode/Reachability/listing6.html.

"ReachableViaWiFiNetwork" and "ReachableViaCarrierDataNetwork" tell you whether you're running over Wifi or 3G respectively.

Thought so, although this might have been a better quote from the readme


Reachability runs asynchronously and will report back changes to the network state and to the reachability of remote hosts as those changes happen.