How to get carrier name in IOS ?

CoreTelephony framework contains routines for accessing telephony-related information (available since iOS 4.0, more information here). CTCarrier class allows you to get some useful information about the user’s home cellular service provider. Let’s use it to get carrier name.

First method will check if CTTelephonyNetworkInfo class is available and will return CTCarrier instance on success.

+ (CTCarrier *) carrier {
if (NSClassFromString(@"CTTelephonyNetworkInfo") == nil) {
return nil;
}
CTTelephonyNetworkInfo *netinfo = [ [ [CTTelephonyNetworkInfo alloc] init] autorelease];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
return carrier;
}

Second method will return carrier name or “Unavailable” string if carrier is not available.

+ (NSString *) carrierName {
CTCarrier *carrier = [self carrier];
if (carrier == nil) {
return @"Unavailable";
} 
return carrier.carrierName; 
}

tips & tricks

Join 7,715 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps AS400 blogging Browser CheatSheets Config CSS DATABASE dsa error Features GUI HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading