SIM CARD DETECTION IN IOS

Mark Devid

Total Post:102

Points:714
Posted by  Mark Devid
Ios  Ios 7 
 1698  View(s)
Ratings:
Rate this:

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 card availabilty

Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));

if([messageClass canSendText]){

    // Sim available

    NSLog(@"Sim available");

}

else{

    //Sim not available

    NSLog(@"Sim not available");

}

if([MFMessageComposeViewController canSendText]){

    // Sim available

    NSLog(@"Sim available");

}

else{

    //Sim not available

    NSLog(@"Sim not available");

}

if([[UIDevice currentDevice].model isEqualToString:@"iPhone"])

{

    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:123456"]])

    {

        NSLog(@"Sim available");

    }

    else

    {

        NSLog(@"Sim not available");

    }

}

I have checked my iphone without sim, it always return @"Sim available". But when i open default "Messages" app and try to send sms it says alert "No SIM Card Installed"... How this message app can detect sim card availabilty?

  1. jacob rasel

    Post:88

    Points:616
    Re: sim card detection in ios

    By the below code you can get the sim card details like carriername,mobilecountrycode,isocountrycode,mobilenetworkcode.In the ios 6 all are retained.So if your sim card is removed also it will retain the old details.So there this idea wont be useful but in ios 7 only carriername is retained and remaining are changed so the below code can be used

    CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];

    CTCarrier* carrier = info.subscriberCellularProvider;

    NSString *mobileCountryCode = carrier.mobileCountryCode;

    NSString *carrierName = carrier.carrierName;

    NSString *isoCountryCode = carrier.isoCountryCode;

    NSString *mobileNetworkCode = carrier.mobileNetworkCode

     

    // Try this to track CTCarrier changes

    info.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier* inCTCarrier) {

            dispatch_async(dispatch_get_main_queue(), ^{

                NSLog(@"User did change SIM");

            });

    };

  1. kang38 kang38

    Post:3

    Points:21
    Re: sim card detection in ios

    gnashes teeth at world cup loss

    The adiPRENE is the material found on the heel area which absorbs impact and shock. Meanwhile, the adiPRENE + is the component that [url=http://www.jerseysauthenticcheapcheap.com]Youth nfl jerseys[/url] permits the forefoot to bounce and step forward easily. The combination of these materials is actually what makes Adidas shoes very effective in releasing energy that helps [url=http://www.jerseyauthenticwholesalejerseys.com]Authentic nfl jerseys[/url] runners propel their foot forward [url=http://www.jerseysfantastics.com]NFL jerseys china[/url] and at the same time reduce impact..

    During the televised interview Blatter was also asked about his future as president of FIFA. He said, contrary to comments last year but in line with several made over the course of this year, that he would run for a fifth term in next year's election. "At the moment I say I want to finish my mandate well.

    "Not enough credit goes to Barnes," Jackson said. "Heres a rookie who is playing a huge role in us being 13 games over.500. He is competing." Curry, who twisted his right ankle in the third quarter of Monday nights win over Toronto, was 6 for 10 from 3 point range as Golden State beat Phoenix for the fourth straight time.

    Manchester City defensive problems were exposed against Cardiff City on the second weekend of the season, a game in which Vincent Kompany was absent. His organization, intelligence and awareness offer City the defensive stability that saw them concede the least goals in the league during the 2010/11, 2011/12 and 2012/13 seasons. An imposing figure, Kompany is a superb modern day central defender with everything in his locker..

    The Germans also play Armenia on June 6, the day before they leave for Brazil.In other games, it was: Paraguay 1, France 1; Belgium 2, Sweden 0; and Israel 4, Honduras 2.In Nice, France, Antoine Griezmann scored his first international goal for France to push for a starting spot at the World Cup, and Paraguay's Victor Caceres tied it with a header in the 89th minute.Griezmann came on as a substitute and [url=http://www.authenticjerseyssupplierssite.com]Cheap authentic jerseys[/url] curled the ball into the right corner of the goal in the 82nd minute.France rested striker Karim Benzema and winger Franck Ribery, who has a back injury.In Stockholm, Romelu Lukaku and Eden Hazard scored after Belgium got off to a slow start.The Belgians took advantage of a Swedish defensive mistake that allowed Axel Witsel to set up Lukaku in the 34th minute. Hazard easily rolled in the second goal in the 78th off a pass by Kevin De Bruyne.Sweden, which played without injured star striker Zlatan Ibrahimovic, had its best chance in the 68th minute when Jimmy Durmaz hit the crossbar after a corner. Ibrahimovic decided to sit out the game just before the start, citing back problems.In Houston, [url=http://www.pursesoutletpursesoutlet.com]Coach handbags outlet[/url] Omer Damari and Gil Vermouth scored in the second half to help Israel beat World Cup bound Honduras 4 2 on Sunday night in an international friendly.

    An intense central defender, Ruthven has started every game and played almost every minute this season, so he has felt those losses deeply. He tries to leave soccer on the field, but it's becoming more difficult. When he brings his work home, he seeks out his dad, a 14 year MLB veteran, or brother Sean, who played baseball at Georgia and later signed with the Rockies.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!