公告
财富商城
积分规则
提问
发文
2020-02-26 11:51发布
We Are One
I want to check if the device has a 2G or 3G connection.
I used Reachability class for network connection check.
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.
最多设置5个标签!
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
added to the CTTelephonyNetworkInfo class. If you want to get notified everytime the connection changes you can listen for:
Heres a code snippet took from the provided link:
I hope this helps you.