以编程方式从 iPhone 检索运营商名称 [英] Retrieving Carrier Name from iPhone programmatically

查看:22
本文介绍了以编程方式从 iPhone 检索运营商名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以编程方式知道 iPhone 上的蜂窝运营商?

Is there a way to know the cell carrier on an iPhone programmatically?

我正在寻找 iPhone 连接到的运营商名称.

I am looking for the carrier name which the iPhone is connected to.

推荐答案

在 iOS 4 中,CoreTelephony 框架是可用的,这里是获取运营商名称的片段:

In iOS 4, the CoreTelephony framework is useable, here's a snippet to get the carrier name:

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);
[netinfo release];

针对 CoreTelephony 的链接并包含在您的标题中:

Link against CoreTelephony and include in your headers:

#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>

这篇关于以编程方式从 iPhone 检索运营商名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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