tags:

views:

731

answers:

4

Hi all,

Though it is relatively straightforward to determine if an iPhone is on Wifi or a data network programmatically in your application, I can't figure out a way to determine if the iPhone is on Edge or 3G.

Anybody figure out a way to determine this?

Note: Not worried about Apple AppStore acceptance policies so I don't mind doing something hacky in my app. (The iPhones should not have to be jailbroken though)

+1  A: 

The iPhone doesn't provide this kind of information to developers programmatically. The best you can hope for is to determine whether a connection to a given host will have to be routed over a cell network - see the SCNetworkReachability reference and the Reachability project for more.

Tim
+1  A: 

Assuming the answer by Tim is right, one way you can tell if the user is on 3G or edge is you can test the speed of the connection by starting a timer having the app download some file from the web and calculate the speed, you should be able to tell if they are on 3G or Edge by the diffrence in speeds.

Daniel
This isn't always reliable - a very poor 3G connection can have the same kind of throughput as a great EDGE connection. It'd be more guesswork than anything. Furthermore, there are other indicators in addition to speed; another big difference between the connections is the time to first response packet (EDGE tends to win out here).
Tim
But the advantage of guesswork based on measured, is that even if you think you are on Edge but really on 3G - you are probably going to do the right thing in using a lower bandwidth transfer if the 3G connection speed is just as slow as Edge would have been.
Kendall Helmstetter Gelner
A: 

one way you can detect iPhone 2G for sure is to look at the device name as reported by the OS

#import <sys/utsname.h>
+ (NSString *)deviceType {
    struct utsname u;
    uname(&u);
    NSString *returnValue = [NSString stringWithFormat:@"%s", u.machine];

    return returnValue;
}

the return value you are looking for is "iPhone1,1" to indicated iPhone 2G. combine this with the Reachability project to tell when they're on a cell network and you you have 1 avenue to guarantee that they are on an edge connection

scootklein
A: 

How exactly can one detect the speed of the connection..??? i just wanna know how to calculate the download speed available..

Rakshak Kalwani