Retrieving Carrier Name from iPhone Programmatically

Retrieving Carrier Name from iPhone programmatically

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 
#import

How can I get details about the device data provider (like Verizon/AT&T) of an iphone programmatically?

You should check the CTCarrier.

Just import CoreTelephony into your Swift file.

Then you can use the carrierName property to get the name of your carrier.

// Setup the Network Info and create a CTCarrier object
let networkInfo = CTTelephonyNetworkInfo()
let carrier = networkInfo.subscriberCellularProvider

// Get carrier name
let carrierName = carrier.carrierName

iOS I can't get my carrier name

Did you explicitly import CTCarrier?

#import 

iPhone - how to determine carrier of the device (AT&T, Verizon, etc?)

1st Import #import as well as #import
(make sure you have the CoreTelephone.framework installed too).

CTTelephonyNetworkInfo *phoneInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *phoneCarrier = [phoneInfo subscriberCellularProvider];
NSLog(@"Carrier = %@", [phoneCarrier carrierName]);
[phoneInfo release];


Related Topics



Leave a reply



Submit