CTCarrier Deprecation issue iOS 16

703 Views Asked by At

Our app is payment related app & we are authenticating device. So, based on sim detection we have implemented feature for authentication. If sim is not present in device then, we have to show alert to the user for "No sim found". As per current deprecation in CTCarrier, We are always getting static details for sim card, so we are not able to detect, either sim is there or not in device. Is there any solution to detect sim is there or not in device? For reference i am providing sample code which i am using:

func simOperatorFor(name: String?, code: String?) -> (String, String) {
        
        var operatorName = "defaultOperator"
        var operatorCode = ""
        let networkInfo = CTTelephonyNetworkInfo()
        if #available(iOS 12.0, *) {
            
            let carriers = networkInfo.serviceSubscriberCellularProviders
            if let keys = carriers?.keys, let carriers = carriers {
                
                for key in keys {
                    operatorName = carriers[key]?.carrierName ?? "defaultOperator"
                    operatorCode = carriers[key]?.mobileNetworkCode ?? ""
                    
                    if let existingName = name, let existingCode = code, !existingName.isEmpty, !existingCode.isEmpty {
                        if operatorName == existingName && operatorCode == existingCode { break }
                    } else {
                        if !operatorName.isEmpty && !operatorCode.isEmpty { break }
                    }
                }
            }
        } else {
            let carrier = networkInfo.subscriberCellularProvider
            operatorName = carrier?.carrierName ?? "defaultOperator"
            operatorCode = carrier?.mobileNetworkCode ?? ""
        }
        
        return (operatorName, operatorCode)
    }
1

There are 1 best solutions below

0
Thisura Dodangoda On

Looks like bad news. The forum pointed to by @Paulw11 has an interesting response by an Apple Tech:

Note this annotation at the top of <CoreTelephonyCTCarrier.h>: CORETELEPHONY_CLASS_DEPRECATED(4_0, 16_0, "Deprecated with no replacement")

This could be Apple trying to implement more stricter privacy regulations, as network operator availability could be used to gather information about the user. However, as a workaround you could design a different method to implement a feature like Device Binding in your application. Here are some suggestions:

  1. You could store the identifierForVendor in a remote Database, and perform a check against it everytime the user logs in to the application.

  2. You could ask the user to verify the ownership of their device with an SMS One Time Password or Time-based One Time Password (TOTP).

  3. You could use the Geolocation capabilities of the device to ensure the user is accessing the Mobile App from a known location such as a city, state or country.