serviceSubscriberCellularProviders behaving Weirdly on Different devices

I am using CoreTelephony's [networkInfo serviceSubscriberCellularProviders] to get details about the carrier of both the SIMs which were present in the device.

I tested this on multiple devices, firstly on an iPhone 11 with a single sim in it, in this case, it was able to retrieve an array of two CTCarrier instances, the first instance had all the values to 0 or the default ones (assuming this was pointing to E-SIM which was empty) and the second instance had the expected values i.e the carrier I am using.

Then I tested this on an iPhone 11 and SE with one e-sim and one regular sim and in both cases, I saw invalid values fetched for carrier names, mobile country code and mobile network code. The carrier name is being received as -- whereas the code was being received as 65535.

I had also tested this on iPhone 14 with a single regular sim in it but here as well I am seeing the invalid values.

So I cannot determine if the issue was due to single sim or dual sim's in the device.

I am also attaching a screenshot from my debugger when I receive these invalid values for reference.

On further research online I found out that 65535, and -- are returned by the iOS when it is unable to get the data from the carrier. But I am not able to figure out how is the same app with exact same logic to retrieve carrier details is working perfectly fine on iPhone 11 with a single regular sim in it.

I also added Privacy- LocalNetworkUsageDescription in the Info.plist of my app to see if that can help, but it too failed.

I am sharing the logic I am using to get the carrier name of both the SIMs present in the device if both exist below:

CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
        if (@available(iOS 12.0, *)) {
            
            NSDictionary *serviceProviders = [networkInfo serviceSubscriberCellularProviders];
            for (NSString *rat in serviceProviders) {
                CTCarrier *carrier = [serviceProviders objectForKey:rat];
                if(carrier == nil) {
                    continue;
                }
                NSString *carrierName = [carrier carrierName];
                if (carrierName) {
                    [_carrier addObject:carrierName];
                }
            }
        } else {
            CTCarrier *carrier = [networkInfo subscriberCellularProvider];
            NSString *carrierName = [carrier carrierName];
            if (carrierName) {
                [_carrier addObject:carrierName];
            }
        }

I am using Xcode 14.3 if that will be helpful.

The carrier name is being received as -- whereas the code was being received as 65535.

That is the new expected behavior on iOS 16.4 and later, because privacy. See this thread for more.

serviceSubscriberCellularProviders behaving Weirdly on Different devices
 
 
Q