iOS网络权限检测(局部监听)
2016-11-21 本文已影响151人
爱恨的潮汐
#pragma mark ============== 联网权限检测(系统会自动弹框提示无需自己弄) ============================
//手机联网权限检测(头文件)
@import CoreTelephony;
-(void)isHaveInternetQX{
//检查联网权限==系统会自动弹框提示无需自己弄==iOS9以后
CTCellularData *cellularData = [[CTCellularData alloc]init];
cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state){
//获取联网状态
switch (state) {
case kCTCellularDataRestricted:
NSLog(@"kCT蜂窝数据限制");
break;
case kCTCellularDataNotRestricted:
NSLog(@"kCT蜂窝数据不受限制的");
break;
case kCTCellularDataRestrictedStateUnknown:
NSLog(@"kCT蜂窝数据限制状态未知");
break;
default:
break;
};
};
}