iOS10 联网权限
联网权限
引入头文件 @import CoreTelephony;
应用启动后,检测应用中是否有联网权限
CTCellularData *cellularData = [[CTCellularData alloc]init];
cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state)
{ //获取联网状态 switch (state) { case kCTCellularDataRestricted: NSLog(@"Restricrted"); break;
case kCTCellularDataNotRestricted: NSLog(@"Not Restricted"); break; case kCTCellularDataRestrictedStateUnknown: NSLog(@"Unknown"); break; default: break;
};};
查询应用是否有联网功能
CTCellularData *cellularData = [[CTCellularData alloc]init];
CTCellularDataRestrictedState state = cellularData.restrictedState; switch (state)
{ case kCTCellularDataRestricted: NSLog(@"kCT蜂窝数据限制"); break;
case kCTCellularDataNotRestricted: NSLog(@"kCT蜂窝数据不受限制的");break;
case kCTCellularDataRestrictedStateUnknown: NSLog(@"kCT蜂窝数据限制状态未知"); break;
default: break;
}