iOS---获取运营商名字

/**

*  获取运营商名字

*

*  @return 运营商名字

*/

+(NSString *)getCarrierName{

    NSString *carrierName = @"";

    CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];

    CTCarrier *ca = networkInfo.subscriberCellularProvider;

    if (ca.carrierName) {

        carrierName = ca.carrierName;

        if ([carrierName isEqualToString:@"中国电信"]) {

            carrierName = @"01";

        }else if ([carrierName isEqualToString:@"中国联通"]){

            carrierName = @"02";

        }else if ([carrierName isEqualToString:@"中国移动"]){

            carrierName = @"03";

        }else{

            carrierName = @"";

        }

    }


    return carrierName;

}

你可能感兴趣的:(iOS---获取运营商名字)