import <CoreTelephony/CTCellularData.h>
CTCellularData *cellularData = [[CTCellularData alloc] init];
// 状态发生变化时调用
cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState restrictedState) {
switch (restrictedState) {
case kCTCellularDataRestrictedStateUnknown:
NSLog(@"蜂窝移动网络状态:未知");
break;
case kCTCellularDataRestricted:
NSLog(@"蜂窝移动网络状态:关闭");
break;
case kCTCellularDataNotRestricted:
NSLog(@"蜂窝移动网络状态:开启");
break;
default:
break;
}
};
image.png
网友评论