I have the following code to obtain the carrier name of my service provider:
let ctTelePhony = CTTelephonyNetworkInfo()
func cellPhoneServices() -> String {
let serviceProvider = ctTelePhony.subscriberCellularProvider
if let carrierName = serviceProvider?.carrierName {
globalCarrierName = carrierName
return carrierName}
else {
globalCarrierName = "Nil"
return "Nil"}
}
According to documentation,subscriberCellular
Provider was deprecated and replaced by serviceSubscriberCellularProviders
, however when making use of that service, it returns nil.
The main question is: when I make use of the code above I get the carrier name, but when I switch to flight mode, I'm still getting my carrier name.
Is the carrier info stored locally on the phone? When making use of the *3001#12345#*
service, all info is not displayed when if flight mode.
@property(nonatomic, readonly, retain) NSString *carrierName;
If we configure a device for a carrier, put device in flight mode, even SIM card is removed still the device return the carrier. The carrier information might be saved inside the device somewhere securely.
This string is provided by the carrier and formatted for presentation to the user. The value does not change if the user is roaming; it always represents the provider with whom the user has an account.
If you configure a device for a carrier and then remove the SIM card, this property retains the name of the carrier.
The value for this property is nil if the device was never configured for a carrier.