Usage of IsSIMInserted in iOS 18

I am developing an iOS application where I need to detect if a SIM card is inserted in the device(either physical / eSim). I am targeting iOS 12 and later. I have tried using CTTelephonyNetworkInfo and CTSubscriber, but I am encountering issues with permissions and API availability in iOS 18 beta 3.

        if #available(iOS 16.0, *) {
            let subscriber = CTSubscriber()
            if #available(iOS 18.0, *) {
                do {
                    if subscriber.isSIMInserted {
                        return "SIM card is inserted."
                    } else {
                        return "No SIM card detected."
                    }
                } catch {
                    return "Error determining if SIM is inserted: \(error.localizedDescription)"
                }
            } else {
                return "isSIMInserted is only available on iOS 18.0 or newer."
            }
        } else {
            return "isSIMInserted is only available on iOS 16.0 or newer."
        }
        
        if let carriers = networkInfo.serviceSubscriberCellularProviders,
           let carrier = carriers.first?.value,
           let _ = carrier.mobileNetworkCode {
            return "SIM card is available.\nCarrier Name: \(carrier.carrierName ?? "None")"
        } else {
            return "No SIM card installed"
        }
    }

in iOS 18 it always returning No SIM card detected.

XCode Version 16.0 beta 3 (16A5202i) iPhone OS: iOS 18.0 (22A5307i)

is there anything did I miss? or any documentation for the implementation would be helpful.

Thanks

Answered by DTS Engineer in 796408022
if the new sim is same network provider then i am not getting triggered. Is this expected?

Yes. The old API has a number of oddities, including:

  • You don’t get an event when the SIM is removed. The API ‘latches’ the state of the SIM.

  • When a new SIM is inserted, you only get an event if the new SIM is from a different provider.

Regarding the new API, let’s focus that discussion over on the other thread you found.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In addition, in iOS 12 to iOS 15, try detecting sim change using the following code,

                guard let self = self else { return }
                let simStatus = self.checkSimAvailability()
                
                DispatchQueue.main.async {
                    self.infolabel.text = "System OS : \(self.systemVersion) \n\n \(simStatus)"
                    self.showSimChangedAlert()
                }
            }

if the new sim is same network provider then i am not getting triggered. Is this expected? whereas if new and old sim are different provider yeah this function triggers as expected. Please consider this question as well. thanks in advance.

Accepted Answer
if the new sim is same network provider then i am not getting triggered. Is this expected?

Yes. The old API has a number of oddities, including:

  • You don’t get an event when the SIM is removed. The API ‘latches’ the state of the SIM.

  • When a new SIM is inserted, you only get an event if the new SIM is from a different provider.

Regarding the new API, let’s focus that discussion over on the other thread you found.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Usage of IsSIMInserted in iOS 18
 
 
Q