首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

iphone 开发 判断 获取 挪动 联通 网络 类型

2012-06-30 
iphone 开发 判断 获取 移动 联通 网络 类型#import UIDevice-IOKitExtensions.h#include sys/types.h

iphone 开发 判断 获取 移动 联通 网络 类型

#import "UIDevice-IOKitExtensions.h"
#include <sys/types.h>
#include <sys/sysctl.h>
#import <mach/mach_host.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <ifaddrs.h>
+ (NSString*)getCarrier:(NSString*)imsi
{
????if (imsi == nil || [imsi isEqualToString:@"SIM Not Inserted"] ) {
????????return @"Unknown";
????}
????else {
????????if ([[imsi substringWithRange:NSMakeRange(0, 3)] isEqualToString:@"460"]) {
????????????NSInteger MNC = [[imsi substringWithRange:NSMakeRange(3, 2)] intValue];
????????????switch (MNC) {
????????????????case 00:
????????????????case 02:
????????????????case 07:
????????????????????return @"China Mobile";
????????????????????break;
????????????????case 01:
????????????????case 06:????
????????????????????return @"China Unicom";
????????????????????break;
????????????????case 03:
????????????????case 05:????
????????????????????return @"China Telecom";
????????????????????break;
????????????????case 20:
????????????????????return @"China Tietong";
????????????????????break;
????????????????default:
????????????????????break;
????????????}
????????}
????}
????return @"Unknown";
}

热点排行