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

3

19

Is there a way to get information about the carrier of iPhones programmatically?

Intricacy answered 17/11, 2011 at 2:6 Comment(0)
M
20

1st Import #import <CoreTelephony/CTTelephonyNetworkInfo.h> as well as #import <CoreTelephony/CTCarrier.h> (make sure you have the CoreTelephone.framework installed too).

CTTelephonyNetworkInfo *phoneInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *phoneCarrier = [phoneInfo subscriberCellularProvider];
NSLog(@"Carrier = %@", [phoneCarrier carrierName]);
[phoneInfo release];
Modernize answered 17/11, 2011 at 2:9 Comment(2)
Notice that this tells you only the original SIM carrier, not current one in case of roaming.Intercourse
this is not working anymore, just returning "Carrier" for me.Litt
S
6

Heres the Swift version:

import CoreTelephony

let phoneInfo = CTTelephonyNetworkInfo()
let phoneCarrier = phoneInfo.subscriberCellularProvider
print(phoneCarrier?.carrierName)
Simonides answered 25/8, 2015 at 14:52 Comment(0)
W
0

While developing in Swift 3.0, You just need to import CoreTelephony in you link binary with libraries in Build phases.

// Setup the Network Info and create a CTCarrier object

 let networkInfo = CTTelephonyNetworkInfo()
 let carrier = networkInfo.subscriberCellularProvider

// Get carrier name

 print(carrier?.carrierName)

That's it.

Wilson answered 5/1, 2017 at 6:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.