2

I need to identify if the phone is connected to wifi which I can accomplish using

    if (status == ReachableViaWiFi) {
        return @"Wifi";
    } else if (status == ReachableViaWWAN)
    {
    //connection type
    CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];

    if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
        return @"2G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
        return @"2G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
        return @"2G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
        return @"3G";
    } else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
        return @"4G";
    }
    }

However, when the phone is using mobile data, I want to get the exact speed - something like 250kbps. I found some blogs where people suggested to download a file and record the time taken for downloading, thereby, calculating the speed. I don't want to use this approach.

Does Apple provide any library to get the speed?

A_G
  • 2,260
  • 3
  • 23
  • 56
  • Hey @Astha Gupta. you need downloading speed or current internet speed? – Maulik Pandya Oct 18 '16 at 12:51
  • 1
    I just googled the difference :) I would require both. – A_G Oct 18 '16 at 13:02
  • 1
    Hey - both are the same http://superuser.com/questions/89814/what-is-the-difference-between-bandwidth-and-download-speed, depends on how we denote it; I can always to bit to byte conversion – A_G Oct 18 '16 at 13:06

1 Answers1

0
  1. If you know exact downloading speed then you needs to use approach said by blog people i.e download a file and record the time taken for downloading, thereby, calculating the speed. no any specific framework for this. using

transfer_speed = bytes_transferred / time_required_for_transfer

you can get downloading speed.

  1. Using knowing network type (2G,3G,4G etc) you can give some specific speed to that network type. but main problem is you are not get exact speed.
Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
  • Is it possible to determine, using any library method, the internet speed when phone connected to wifi? – A_G Oct 19 '16 at 06:52