Iphone SIM card information

Source: Internet
Author: User

/*

Iphone SIM card information

1. Add a Framework (CoreTelephony. framework ).

2. Introduce the header file


# Import <CoreTelephony/CTTelephonyNetworkInfo. h>

# Import <CoreTelephony/CTCarrier. h>

3. Initialization

 
*/

//-----------------------------------

Demo
//-----------------------------------

# Import <UIKit/UIKit. h>

# Import <CoreTelephony/CTTelephonyNetworkInfo. h>

# Import <CoreTelephony/CTCarrier. h>

 

@ Interface RootViewController: UITableViewController

{

// Declare Variables

CTTelephonyNetworkInfo * networkInfo;

}

@ End

 

 

@ Implementation RootViewController


-(Void) viewDidLoad

{

[Super viewDidLoad];

Self. navigationItem. prompt = @ "CTTelephonyNetworkInfo ";

Self. navigationItem. title = @ "CTCarrier ";


// Initialization

NetworkInfo = [[CTTelephonyNetworkInfo alloc] init];

// This window is displayed when the SIM card is changed

NetworkInfo. subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier ){

UIAlertView * alert = [[UIAlertView alloc] initWithTitle: nil message: @ "Sim card changed" delegate: nil cancelButtonTitle: @ "Dismiss" otherButtonTitles: nil];

[Alert show];


};


}

 

 

 

 

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath

{

// Obtain SIM card information

CTCarrier * carrier = networkInfo. subscriberCellularProvider;

Static NSString * CellIdentifier = @ "Cell ";

UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];

If (cell = nil ){

Cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: CellIdentifier];

}


Switch (indexPath. row ){

Case 0: // Supplier name (China Unicom China Mobile)

Cell. textLabel. text = @ "carrierName ";

Cell. detailTextLabel. text = carrier. carrierName;

Break;

Case 1: // country ID

Cell. textLabel. text = @ "mobileCountryCode ";

Cell. detailTextLabel. text = carrier. mobileCountryCode;

Break;

Case 2: // supplier network ID

Cell. textLabel. text = @ "mobileNetworkCode ";

Cell. detailTextLabel. text = carrier. deleenetworkcode;

Break;

Case 3:

Cell. textLabel. text = @ "isoCountryCode ";

Cell. detailTextLabel. text = carrier. isoCountryCode;

Break;

Case 4: // whether voip is allowed

Cell. textLabel. text = @ "allowsVOIP ";

Cell. detailTextLabel. text = carrier. allowsVOIP? @ "YES": @ "NO ";

Break;


Default:

Break;

}


Return cell;

}

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.