聯(lián)網(wǎng)權(quán)限
引入頭文件 @import CoreTelephony;
應(yīng)用啟動(dòng)后,檢測(cè)應(yīng)用中是否有聯(lián)網(wǎng)權(quán)限
CTCellularData *cellularData = [[CTCellularData alloc]init];
cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state)
{ //獲取聯(lián)網(wǎng)狀態(tài) switch (state) { case kCTCellularDataRestricted: NSLog(@"Restricrted"); break;
case kCTCellularDataNotRestricted: NSLog(@"Not Restricted"); break; case kCTCellularDataRestrictedStateUnknown: NSLog(@"Unknown"); break; default: break;
};};
查詢應(yīng)用是否有聯(lián)網(wǎng)功能
CTCellularData *cellularData = [[CTCellularData alloc]init];
CTCellularDataRestrictedState state = cellularData.restrictedState; switch (state)
{ case kCTCellularDataRestricted: NSLog(@"kCT蜂窩數(shù)據(jù)限制"); break;
case kCTCellularDataNotRestricted: NSLog(@"kCT蜂窩數(shù)據(jù)不受限制的");break;
case kCTCellularDataRestrictedStateUnknown: NSLog(@"kCT蜂窩數(shù)據(jù)限制狀態(tài)未知"); break;
default: break;
}