swift 3.0 ctradioaccessprimitive technologyygprs 怎么调用

objective c - Determining 3G vs Edge - Stack Overflow
Learn, Share, Build
Each month, over 50 million developers come to Stack Overflow to learn, share their knowledge, and build their careers.
Join the world’s largest developer community.
Display name
Email address
By registering, you agree to the
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 3G or EDGE?
No, there is no such thing as a public detection of network technology within the cell connectivity.
25.7k1173112
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
usingBlock:^(NSNotification *note)
NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
Read up more on
6,35033172
Marginally simplified version of nst's code to silence compiler warnings I got in XCode 4.5:
- (NSNumber *) dataNetworkTypeFromStatusBar {
UIApplication *app = [UIApplication sharedApplication];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"]
subviews];
NSNumber *dataNetworkItemView =
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
dataNetworkItemView =
return [dataNetworkItemView valueForKey:@"dataNetworkType"];
And the value keys I've found so far:
0 = No wifi or cellular
1 = 2G and earlier? (not confirmed)
2 = 3G? (not yet confirmed)
1,39611215
Using private APIs, you can read this information directly in the status bar.
+ (NSNumber *)dataNetworkTypeFromStatusBar {
UIApplication *app = [UIApplication sharedApplication];
UIStatusBar *statusBar = [app valueForKey:@"statusBar"];
UIStatusBarForegroundView *foregroundView = [statusBar valueForKey:@"foregroundView"];
NSArray *subviews = [foregroundView subviews];
UIStatusBarDataNetworkItemView *dataNetworkItemView =
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
dataNetworkItemView =
return [dataNetworkItemView valueForKey:@"dataNetworkType"];
3,72912439
telephonyInfo.currentRadioAccessTechnology Values:
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyGPRS
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyEdge
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyWCDMA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyHSDPA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyHSUPA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMA1x
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORev0
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORevA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORevB
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyeHRPD
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyLTE __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
I think that these are all the possible values.
1,21411121
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledThe page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.分类:&&922人阅读&&&
昨晚看一篇文章时看到了私有API这个词,貌似开发者对私有API的使用很反感,可惜我连私有API是什么都不知道(惭愧惭愧),于是果断百度谷歌,以下是Stackoverflow中关于Private Frameworks的一个解释:
Private frameworks are frameworks which you are not allowed to use. They are not expected to be used outside of Apple, hence &Private&. They are often lower-level libraries which may &break& the system if not used correctly.
(But the frameworks have to exist because Apple's apps and public frameworks do use the private frameworks.)&
Since the private frameworks are not for public use, Apple doesn't need to give any headers or documentations away.
If you're writing for AppStore, you should not use private frameworks (unless you're from Apple). The system will immediately reject your app even before the review process begins.&
(On the other hand, for jailbroken platforms you're free to use any frameworks. Even so, the APIs of private frameworks is unstable, that you should avoid them if possible.&
There is an ongoing effort to document these private frameworks and API inhttp://iphonedevwiki.net/index.php/Main_Page.)
私有框架我们可以在SDK目录中找到,详细目录如下:
一大堆,里面就提供了私有API,这些私有框架苹果并不提倡我们使用,私有框架中没有给出头文件(好像可以导出)而且也没有官方的文档说明,一旦app中使用了私有API,那么审核将无法通过(但是据说Google的GoogleVoice使用了私有API并且通过了审核,背后发生了什么我们不得而知)。但是私有API的功能貌似非常强大,更加是越狱开发的必备工具。
于是我很好奇地想玩下私有API,搜到了一个CoreTelephony框架,貌似在iOS 6以前该框架是私有框架,但来到iOS 7该框架绝对是个公开的框架了,因为我在PrivateFrameworks目录下找不到该框架,相反在上一层中的Frameworks目录下找到了该框架:
Apple官网也给出了该框架的文档:
无论如何,先试玩下这个框架。
参考网上的一篇文章(10年写的,那个时候CoreTelephony框架应该还是个私有框架吧),简单使用了一下该框架,用来输出手机的运营商信息和简单的通话信息。
首先要导入CoreTelephony框架:
这里使用了@import关键字,所以要确保Enable Modules选项已经打开:
然后声明一个CTCallCenter变量,该变量非strong属性,所以不会导致在代码块中使用时形成retain cycle的问题:
接着编写获取运营商信息的方法:
最后在viewDidLoad方法中注册通话事件的处理代码块:
这里有一点比较奇怪,如果我不使用CTCallCenter的currentCalls属性,那么将无法输出代码块中的参数call的信息。
代码很简单,功能也很有限,下面真机调试下(模拟器输出为null,这个不用解释了吧)。
启动程序,控制台输出信息如下:
Radion Acess Technology的值包括:
以上信息指的是手机的数据业务吧,我的是Edge,不知道是什么,搜了一下:
GPRS:(General Packet Radio Service),它是GSM移动电话用户可用的一种移动数据业务, 是GSM的技术升级,属于2.5G,简单讲就是网速更快了。&
EDGE:(Enhanced Data Rate for GSM Evolution),即增强型数据速率GSM演进技术。 是GPRS的技术升级,属于2.75G。&
EDGE和GPRS同属于从GSM到3G的过渡技术。
之后另外拿台手机打入本机,并且Descline,输出如下:
可以看到通话状态由Incoming到Disconnected,在断开通话时current calls变为nil了。
那么该app可不可以在后台监控通话事件呢?答案是不行。
1.你可以让手机进入后台,然后用另外一台手机打入本机,控制台没有关于通话信息的输出。
2.你可以尝试用本机打电话出去,此时我们调用了系统的Phone程序,Demo程序已经进入了后台,无法监听到任何通话信息。
3.用别的手机打入本机,选择Answer(话费要钱,调试完不要忘记断开通话啊),此时系统将调用Phone程序,Demo程序进入后台,所以在控制台输出中我们找不到Disconnected的通知:
本文简单使用了一下CoreTelephony这个曾经的私有框架,等以后真正用上私有API时再写文章做下笔记吧。
Demo已上传:
参考资料:
本文已收录于以下专栏:
相关文章推荐
使用私有API——CoreTelephony获取本机号码
步骤如下:
1)导入CoreTelephony这个private framework
2)在xxx.m中加入红字部分:
本文简单地使用了CoreTelephony这个曾经的私有框架来输出手机的运营商信息和通话信息。
昨晚看一篇文章时看到了私有API这个词,貌似开发者对私有API的使用很反感,可惜我连私有API是什么都不知道(惭愧惭愧),于是果断百度谷歌,以下是Stackoverflow中关于Private Fra...
昨晚看一篇文章时看到了私有API这个词,貌似开发者对私有API的使用很反感于是果断百度谷歌,以下是Stackoverflow中关于Private Frameworks的一个解释:
Private...
转自:http://blog.csdn.net/yhawaii/article/details/7585063
OS 4.0 的官方 API 里头,多了一个叫做 Core Telephony...
以下转自 http://zonble.net/archives/0.php,注意要加头文件目录
/System/Library/Frameworks/CoreTelephon...
注意要加头文件目录 /System/Library/Frameworks/CoreTelephony.framework/Headers 到 build 设置 Header Search Paths,...
使用CoreTelephony获得SIM卡网络运营商名称
http://zonble.net/archives/0.php,注意要加头文件目录 /System/Library/Frameworks/CoreTelephon...
他的最新文章
讲师:AI100
讲师:谢梁
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)10288人阅读
iOS Frameworks(2)
昨晚看一篇文章时看到了私有API这个词,貌似开发者对私有API的使用很反感,可惜我连私有API是什么都不知道(惭愧惭愧),于是果断百度谷歌,以下是Stackoverflow中关于Private Frameworks的一个解释:
Private frameworks are frameworks which you are not allowed to use. They are not expected to be used outside of Apple, hence &Private&. They are often lower-level libraries which may &break& the system if not used correctly.
(But the frameworks have to exist because Apple's apps and public frameworks do use the private frameworks.)&
Since the private frameworks are not for public use, Apple doesn't need to give any headers or documentations away.
If you're writing for AppStore, you should not use private frameworks (unless you're from Apple). The system will immediately reject your app even before the review process begins.&
(On the other hand, for jailbroken platforms you're free to use any frameworks. Even so, the APIs of private frameworks is unstable, that you should avoid them if possible.&
There is an ongoing effort to document these private frameworks and API inhttp://iphonedevwiki.net/index.php/Main_Page.)
私有框架我们可以在SDK目录中找到,详细目录如下:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/PrivateFrameworks/
一大堆,里面就提供了私有API,这些私有框架苹果并不提倡我们使用,私有框架中没有给出头文件(好像可以导出)而且也没有官方的文档说明,一旦app中使用了私有API,那么审核将无法通过(但是据说Google的GoogleVoice使用了私有API并且通过了审核,背后发生了什么我们不得而知)。但是私有API的功能貌似非常强大,更加是越狱开发的必备工具。
于是我很好奇地想玩下私有API,搜到了一个CoreTelephony框架,貌似在iOS 6以前该框架是私有框架,但来到iOS 7该框架绝对是个公开的框架了,因为我在PrivateFrameworks目录下找不到该框架,相反在上一层中的Frameworks目录下找到了该框架:
Apple官网也给出了该框架的文档:
无论如何,先试玩下这个框架。
参考网上的一篇文章(10年写的,那个时候CoreTelephony框架应该还是个私有框架吧),简单使用了一下该框架,用来输出手机的运营商信息和简单的通话信息。
首先要导入CoreTelephony框架:
// 首先导入CoreTelephony框架
@import CoreT
这里使用了@import关键字,所以要确保Enable Modules选项已经打开:
然后声明一个CTCallCenter变量,该变量非strong属性,所以不会导致在代码块中使用时形成retain cycle的问题:
@interface ViewController () {
CTCallCenter *center_; // 为了避免形成retain cycle而声明的一个变量,指向接收通话中心对象
接着编写获取运营商信息的方法:
- (void)getCarrierInfo {
// 获取运营商信息
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = info.subscriberCellularP
NSLog(@&carrier:%@&, [carrier description]);
// 如果运营商变化将更新运营商输出
info.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier) {
NSLog(@&carrier:%@&, [carrier description]);
// 输出手机的数据业务信息
NSLog(@&Radio Access Technology:%@&, info.currentRadioAccessTechnology);
最后在viewDidLoad方法中注册通话事件的处理代码块:
- (void)viewDidLoad
[super viewDidLoad];
// 获取并输出手机的运营商信息
[self getCarrierInfo];
// 监控通话信息
CTCallCenter *center = [[CTCallCenter alloc] init];
center.callEventHandler = ^(CTCall *call) {
NSSet *curCalls = center_.currentC
NSLog(@&current calls:%@&, curCalls);
NSLog(@&call:%@&, [call description]);
这里有一点比较奇怪,如果我不使用CTCallCenter的currentCalls属性,那么将无法输出代码块中的参数call的信息。
代码很简单,功能也很有限,下面真机调试下(模拟器输出为null,这个不用解释了吧)。
启动程序,控制台输出信息如下:
14:48:31.711 GetMyPhone[762:60b] carrier:CTCarrier (0x) {
Carrier name: [中国移动]
Mobile Country Code: [460]
Mobile Network Code:[07]
ISO Country Code:[cn]
Allows VOIP? [YES]
14:48:31.713 GetMyPhone[762:60b] Radio Access Technology:CTRadioAccessTechnologyEdge
Radion Acess Technology的值包括:
* Radio Access Technology values
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyGPRS
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyEdge
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyWCDMA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyHSDPA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyHSUPA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMA1x
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORev0
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORevA
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyCDMAEVDORevB
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyeHRPD
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
CORETELEPHONY_EXTERN NSString * const CTRadioAccessTechnologyLTE
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_7_0);
以上信息指的是手机的数据业务吧,我的是Edge,不知道是什么,搜了一下:
GPRS:(General Packet Radio Service),它是GSM移动电话用户可用的一种移动数据业务, 是GSM的技术升级,属于2.5G,简单讲就是网速更快了。&
EDGE:(Enhanced Data Rate for GSM Evolution),即增强型数据速率GSM演进技术。 是GPRS的技术升级,属于2.75G。&
EDGE和GPRS同属于从GSM到3G的过渡技术。
之后另外拿台手机打入本机,并且Descline,输出如下:
14:48:38.727 GetMyPhone[762:1803] current calls:{(
CTCall (0x) {
callState: [CTCallStateIncoming]
Call ID: [E3E1D27E--925EDC2]
14:48:38.739 GetMyPhone[762:1803] call:CTCall (0x) {
callState: [CTCallStateIncoming]
Call ID: [E3E1D27E--925EDC2]
14:48:42.684 GetMyPhone[762:1803] current calls:(null)
14:48:42.710 GetMyPhone[762:1803] call:CTCall (0x) {
callState: [CTCallStateDisconnected]
Call ID: [E3E1D27E--925EDC2]
可以看到通话状态由Incoming到Disconnected,在断开通话时current calls变为nil了。
那么该app可不可以在后台监控通话事件呢?答案是不行。
1.你可以让手机进入后台,然后用另外一台手机打入本机,控制台没有关于通话信息的输出。
2.你可以尝试用本机打电话出去,此时我们调用了系统的Phone程序,Demo程序已经进入了后台,无法监听到任何通话信息。
3.用别的手机打入本机,选择Answer(话费要钱,调试完不要忘记断开通话啊),此时系统将调用Phone程序,Demo程序进入后台,所以在控制台输出中我们找不到Disconnected的通知:
14:47:07.946 GetMyPhone[751:3407] current calls:{(
CTCall (0x) {
callState: [CTCallStateIncoming]
Call ID: [140AF363-434D-41EE-BDC9-]
14:47:07.959 GetMyPhone[751:3407] call:CTCall (0x) {
callState: [CTCallStateIncoming]
Call ID: [140AF363-434D-41EE-BDC9-]
14:47:15.836 GetMyPhone[751:1807] current calls:{(
CTCall (0x) {
callState: [CTCallStateConnected]
Call ID: [140AF363-434D-41EE-BDC9-]
14:47:15.855 GetMyPhone[751:1807] call:CTCall (0x) {
callState: [CTCallStateConnected]
Call ID: [140AF363-434D-41EE-BDC9-]
本文简单使用了一下CoreTelephony这个曾经的私有框架,等以后真正用上私有API时再写文章做下笔记吧。
Demo已上传:
参考资料:
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:967092次
积分:10419
积分:10419
排名:第1680名
原创:173篇
转载:65篇
评论:98条
(8)(1)(1)(4)(7)(25)(7)(17)(13)(22)(32)(7)(18)(36)(16)(9)(13)(2)(1)
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'

我要回帖

更多关于 technology 的文章

 

随机推荐