Search code examples
iphoneiossdkmfmessagecomposeviewcontroller

How to check if sim card is installed or not


I am developing an app which has call and message functionality , i want to check if sim card is installed or not coz i am facing problem with messaging as it gives alerts for " Message Sent Successful"

Please help me out.


Solution

  • There might be different ways but one way is by using MFMessageComposeViewController class to see if you can send the text message. If you can then sim is available otherwise not.

    if ([MFMessageComposeViewController canSendText]) {
        NSLog(@"SIM Available");
    } else {
        NSLog(@"no SIM card installed");
    }
    

    In cases you have iMessage available then this might return you true, you could also check if you can make a call, you might want to use CTTelephonyNetworkInfo for that purpose.