ragu ragu - 5 months ago 10
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];
return;
}


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

Answer

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")
    }else{
        NSLog("available")     
    }
Comments