iOS10 联网权限

2016-12-16  本文已影响87人  大虾咪

联网权限
引入头文件 @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;
}

上一篇下一篇

猜你喜欢

热点阅读