OGeek|极客世界-中国程序员成长平台

标题: iphone - 获取 iPhone 运营商接收状态? (不是互联网) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:45
标题: iphone - 获取 iPhone 运营商接收状态? (不是互联网)

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

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

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



Best Answer-推荐答案


将您的应用程序与 CoreTelephony.framework

相关联

您可以检查 CTCarrier 对象,看看对于某些需要与 Phone Provider 连接的属性是否有有效结果 (!=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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4