Determining 3G vs Edge

后端 未结 5 1140
青春惊慌失措
青春惊慌失措 2020-11-27 03:08

I know that the reachability example allows detection of whether network is accessible via Wifi or Cell, but is there a way to determine whether the cell connection is over

5条回答
  •  广开言路
    2020-11-27 03:44

    As of iOS 7, there's now a public way to do so:

    CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
    NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
    [NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification 
                                                    object:nil 
                                                     queue:nil 
                                                usingBlock:^(NSNotification *note) 
    {
        NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
    }];
    

    Read up more on my article in objc.io.

提交回复
热议问题