iOS 获取网络制式

/**
 *  获取网络制式
 *
 *  @return 网络制式
 */
+ (NSString *)getCarrierName
{
    NSString *tt = [[NSString alloc] init];
    CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier *carrier = [netinfo subscriberCellularProvider];
    NSString *carrierName = [carrier carrierName];
    
    if (nil != carrierName)
    {
        NSRange range = [carrierName rangeOfString:@"移动"];
        if (range.length > 0)
        {
            tt = [tt stringByAppendingString:@"cmcc"];
        }
        else
        {
            range = [carrierName rangeOfString:@"联通"];
            if (range.length > 0)
            {
                tt = [tt stringByAppendingString:@"cu"];
            }
            else
            {
                tt = [tt stringByAppendingString:@"ct"];//电信
            }
        }
    }
    else
    {
        tt = [tt stringByAppendingString:@""];
    }

    return tt;
}

你可能感兴趣的:(iOS 获取网络制式)