I have a iphone app that has the capability to send messages. I want to alert user when sim card is not available in iphone. So i tried below three function to check sim car
Complementing the Anneq Anwar answer, here the swift version:
import CoreTelephony
func isSimAvailable() -> Bool {
var isSimCardAvailable = true
var info = CTTelephonyNetworkInfo()
var carrier = info.subscriberCellularProvider
if carrier != nil && carrier.mobileNetworkCode == nil || carrier.mobileNetworkCode.isEqual("") {
isSimCardAvailable = false
}
return isSimCardAvailable
}
fix: The carrier can be nil in some devices