美文网首页
iOS10 联网权限

iOS10 联网权限

作者: 大虾咪 | 来源:发表于2016-12-16 14:42 被阅读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;
    }

    相关文章

      网友评论

          本文标题:iOS10 联网权限

          本文链接:https://www.haomeiwen.com/subject/ttvnmttx.html