Get iPhone Carrier Reception Status? (not internet)

1.9k views Asked by At

I need to know if the user could theoretically make a phone call.

Does anyone know how to "return true" (using Cocoa iOS) when the user's iPhone is able to connect to the carrier's network? (not the internet)

Or how to programmatically tell "how many bars of reception" the user has?

1

There are 1 answers

1
valvoline On

Link your application against the CoreTelephony.framework

You can check the CTCarrier object and see if you've a valid result (!=nil) for some property that require a connection with the Phone Provider.

For example, below there's a snip of code that check against the mobileNetworkCode property of CTCarrier. This property is != nil if-and-only-if the device is connected to a Phone Provider (your desired task, user able to make a phone call, is included in the state described above).

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.

};

more info at the Apple Developer Documentation url: http://developer.apple.com/library/IOs/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html