Retrieving Carrier Name from iPhone programmatically
Is there a way to know the cell carrier on an iPhone programmatically?
I am looking for the carrier name which the iPhone is connected to.
Solution 1:
In iOS 4, the CoreTelephony framework is useable, here's a snippet to get the carrier name:
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);
[netinfo release];
Link against CoreTelephony and include in your headers:
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
Solution 2:
Just to make a note here.. I tested this API on different SIMs and it seems that the name of the operator the iPhone is locked to is returned with [carrer carrierName]!!
I tested this on 2 iphones, one locked and the other not, and for the locked one, regardless of the SIM provider, it returns the name of the operator it is locked to everytime i run my test app. Note however that the MNC does change!
Solution 3:
For swift users you can try this:
import CoreTelephony
static var carrierName:String? {
let networkInfo = CTTelephonyNetworkInfo()
let carrier = networkInfo.subscriberCellularProvider
return carrier?.carrierName
}
Solution 4:
There is no public API for getting the carrier name. If you don't need to publish on the App Store you could look at using private api's.
VVCarrierParameters.h
in the VisualVoiceMail package seems to have a carrierServiceName
class method that might be what you need. Drop that header in your project and call [VVCarrierParameters carrierServiceName]
.
Note your app will most likely be rejected if you do this.