How to determine whether user is on Edge or 3G on iPhone

前端 未结 4 1163

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 i

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 03:04

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

    #import 
    + (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

提交回复
热议问题