#import <CoreTelephony/CTCellularData.h>
- (void)cellularData{
// 应用启动后,检测应用中是否有联网权限
CTCellularData *cellularData = [[CTCellularData alloc] init];
cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state){
switch(state) {
case kCTCellularDataRestricted:
// app网络权限受限
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
break;
case kCTCellularDataRestrictedStateUnknown:
// app网络权限不确定
// 各种操作
break;
case kCTCellularDataNotRestricted:
// app网络权限不受限
// 各种操作
break;
default:
break;
}
};
}
+ (CTCellularDataRestrictedState)getCellularDataRestrictionState {
CTCellularData *cellularData = [[CTCellularData alloc] init];
CTCellularDataRestrictedState restrictedState = cellularData.restrictedState;
returnrestrictedState;
}
网友评论