Objective-C determine data network type of the iOS device

后端 未结 3 495
一生所求
一生所求 2020-12-23 10:24

Im on an application that receive data from server, the problem is when user connect to cellular data (Not 3G or WIFI), it take ages t

相关标签:
3条回答
  • 2020-12-23 11:07

    case 1, with the NSLog(@"2G"); is the case where the phone is on regular cellular data, not 3G, not 4G, and not WiFi.

    What you should do is insert code below the NSLog for 2G to prevent the data transfer.

    0 讨论(0)
  • 2020-12-23 11:13

    Make sure that the Status bar is not hidden in your application. if it's not visible it will always return No wifi or cellular because your code reads the text in the Status bar thats all.

    this is the best way to solve your problem, just make the Status bar not hidden then the application will get the text about the network type.

    0 讨论(0)
  • 2020-12-23 11:21

    if using iOS 7+ then you can get information from CoreTelephony framework following method :

    CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
    NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
    

    Possibles values defined which you will get are as follows : CTRadioAccessTechnologyGPRS, CTRadioAccessTechnologyEdge ,CTRadioAccessTechnologyWCDMA , CTRadioAccessTechnologyLTE etc

    0 讨论(0)
提交回复
热议问题