ragu ragu - 1 year ago 44
iOS Question

Sim Card detection is not working in my iphone app?

My code is:

if(![MFMessageComposeViewController canSendText]) {
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];

It works correctly with simulator but not working in iPhone without a SIM card.

Answer Source

Use this code might be help you.

 CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier* carrier = info.subscriberCellularProvider;

    if(carrier.mobileNetworkCode == nil || [carrier.mobileNetworkCode isEqualToString:@""])
        NSLog("Not available")