在iPhone中获取操作员详细信息 [英] getting operator details in iphone

查看:173
本文介绍了在iPhone中获取操作员详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取iPhone当前使用的操作员详细信息(如Airtel或Idea等等)。

How to get the currently using operator details (like Airtel or Idea or etc..)of iPhone.

是否可以获取这些详细信息或是否有任何详细信息我正在开发一个基于操作员的应用程序,如果用户更改了他的SIM(操作员),那么应用程序不应该工作,它必须适用于该特定的操作员。

Is it possible to get those details or is there any way to identify which operator currently we are using.I am developing an application which is based on the operator, if user changes his SIM(Operator) then the app shouldn't work, it has to work for that particular operator.

推荐答案

CTCarrier 应该包含您需要的信息。

CTCarrier should have the info you need in it.

编辑: CTTelephonyNetworkInfo 响应用户在会话中切换SIM,并提供一个 CTCarrier 的实例。

CTTelephonyNetworkInfo responds to a user switching SIMs mid-session, and provides an instance of CTCarrier for you.

示例代码(在你的app delegat中) e):

Sample code (in your app 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;
}

请注意以下关于 CTCarrier <属性的建议/ code>(如果读取零运营商,我建议不要进行永久单向锁定):

Note the following advisory on the properties of CTCarrier (I would recommend not doing a permanent one-way lock if a nil carrier is read):

此属性的值为 nil 如果符合以下任何条件:

"The value for this property is nil if any of the following apply:


  • 设备处于飞行模式。

  • 设备中没有SIM卡。

  • 设备不在手机服务范围内。

要验证的 CTCarrier 的属性,我建议 carrierName 特别是当用户漫游时它不会改变,因此只要SIM卡与您想要的操作员绑定,应用程序仍然可以正常工作。

Of the properties of CTCarrier to validate on, I would recommend carrierName specifically as it doesn't change when the user is roaming so the app will still work as long as the SIM is tied to your desired operator.

这篇关于在iPhone中获取操作员详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆