Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 466
thierryb Avatar asked May 12 '09 15:05

thierryb


3 Answers

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>
like image 97
George Zhu Avatar answered Nov 20 '22 17:11

George Zhu


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!

like image 29
Abolfoooud Avatar answered Nov 20 '22 16:11

Abolfoooud


For swift users you can try this:

import CoreTelephony

static var carrierName:String? {
    let networkInfo = CTTelephonyNetworkInfo()
    let carrier = networkInfo.subscriberCellularProvider
    return carrier?.carrierName
}
like image 4
Sanif SS Avatar answered Nov 20 '22 17:11

Sanif SS