How to check network 2G or 3G in IOS? [duplicate]

我是研究僧i 提交于 2020-01-21 02:09:13

问题


I want to check if the device has a 2G or 3G connection.

I used Reachability class for network connection check.


回答1:


In iOS 7 Apple provided a new way to get it.

Please read this link. The "Know your Radio" section.

The basic idea is to use the new

currentRadioAccessTechnology

added to the CTTelephonyNetworkInfo class. If you want to get notified everytime the connection changes you can listen for:

CTRadioAccessTechnologyDidChangeNotification

Heres a code snippet took from the provided link:

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);
}];

I hope this helps you.



来源:https://stackoverflow.com/questions/20042445/how-to-check-network-2g-or-3g-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!