iphone - 获取 iPhone 运营商接收状态? (不是互联网)

标签 iphone ios cocoa signal-strength carrier

我需要知道用户理论上是否可以调用电话。

有谁知道当用户的 iPhone 能够连接到运营商的网络时如何“返回 true”(使用 Cocoa iOS)? (不是互联网)

或者如何以编程方式告知用户有“多少个接收格”?

最佳答案

将您的应用程序链接到CoreTelephony.framework

您可以检查 CTCarrier 对象,看看是否有某些需要与电话提供商连接的属性的有效结果 (!=nil)。

例如,下面有一段代码,用于检查 CTCarriermobileNetworkCode 属性。当且仅当设备连接到电话提供商时,此属性为 != nil(您所需的任务,即用户能够调用电话,包含在上述状态中)。

CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];

//The value for this property is nil if any of the following apply:
//  - The device is in Airplane mode.
//  - There is no SIM card in the device.
//  - The device is outside of cellular service range.
NSString *mnc = [carrier mobileNetworkCode]; 

if(!mnc) {
    //if we're here, than probably we're disconnected from the Phone Provider
}

netInfo.subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier) {
    //this block is executed each time we've a change to the state of the carrier
    //be sure to check the carrier object, in order to see is we're connected to a
    //phone provider.

};

更多信息请访问 Apple 开发者文档网址:http://developer.apple.com/library/IOs/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html

关于iphone - 获取 iPhone 运营商接收状态? (不是互联网),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8892860/

相关文章:

objective-c - 使用 Cocoa 确定两个日期之间的月数

ios - 如何设置 UIActivityViewController Gmail 共享主题不同于正文

iphone - 如果你有很多静态数据,如何遵循 MVC?

ios - “DBOfflineOrder”没有主键,无法快速更新 Realm

IOS 7 iphone 录音应用错误 : AudioQueueStart failed (-50)

php - 使用 Cocoa 查询数据库

objective-c - Cocoa Touch/Objective-C 中的向量

iphone - 如何将最低要求的 iOS 版本设置为 5.0.1

ios - 在 Cordova 构建 ios 期间找不到团队 ID 的代码签名错误

ios - iOS如何在一个巨大的字符串的2个字符串之间找到多个字符串?