Getting information about operators in iphone

How to get information about the current use of the operator (for example, Airtel or Idea, etc.) iPhone.

Is it possible to get this data or is there a way to determine which operator we are currently using. I am developing an operator-based application, if the user changes their SIM-card (Operator), then the application should not work, it should work for this particular operator.

+3
source share
3 answers

CTCarrier should have the information you need.

Edit: CTTelephonyNetworkInfo responds to a user switching a SIM session, and provides you with a CTCarrier instance.

Sample code (in the application delegate):

 #import <CoreTelephony/CoreTelephony.h> static NSString *requiredCarrier = @"Verizon"; // example carrier - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CTTelephonyNetworkInfo *myNetworkInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *myCarrier = [myNetworkInfo subscriberCellularProvider]; if(![[myCarrier carrierName] isEqualToString:requiredCarrier]) { // lock the app, possibly terminate the app after displaying a UIAlertView // informing the user of the network-lock. } // ... return YES; } 

Pay attention to the following message about the properties of CTCarrier (I would recommend not to perform permanent one-way locking if zero carrier is read):

"The value for this property is nil if one of the following conditions applies:

  • The device is in flight mode.
  • The device does not have a SIM card.
  • The device is out of cellular range.

From the CTCarrier properties for checking, I would recommend carrierName specifically, since it does not change when the user is roaming, so the application will work as long as the SIM card is attached to your desired operator.

+9
source

Just pay attention if someone is looking for this. I noticed that when playing with the CTCarrier API, "nil" returns to any of its properties only on the emulator. For some reason, it returns @ "(empty string) on ​​the device! Checking again nil failed on the device, but checking for equality with @" "works!

+1
source

To achieve this, you can use the basic telephony infrastructure. In particular, the CTCarrier property and carrierName . Check out the documentation here: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html%23//apple_ref/doc/uid/TP40009596

0
source

Source: https://habr.com/ru/post/915129/


All Articles