MyException - 我的异常网
当前位置: 我的异常网 » Iphone » iphone 开发 判断 获取 挪动 联通 网络 类型

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

www.MyException.Cn,网友分享于:2012-06-30   浏览:26次
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";
}

软件开发程序错误异常Exception Copyright © 2009-2015 MyException 版权所有