ios判断蓝牙是否开启
2015-03-24 21:49
302 查看
在做ibeacon 模块时,首先要判断蓝牙是否开着。那么问题来了,怎么样用代码判断蓝牙开着呢?
查了API,发现CBCentralManager可以实现。
首先要完成协议 CBCentralManagerDelegate
@property CBCentralManager *centralManager;
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
查了API,发现CBCentralManager可以实现。
首先要完成协议 CBCentralManagerDelegate
@property CBCentralManager *centralManager;
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
-(void)centralManagerDidUpdateState:(CBCentralManager *)central { //第一次打开或者每次蓝牙状态改变都会调用这个函数 if(central.state==CBCentralManagerStatePoweredOn) { NSLog(@"蓝牙设备开着"); _canShake=YES; } else { NSLog(@"蓝牙设备关着"); UIAlertView *alterView=[[UIAlertView alloc]initWithTitle:@"亲,请打开蓝牙哦" message:@"打开蓝牙摇一摇,优惠就会出现哦~" delegate:self cancelButtonTitle:@"好的。" otherButtonTitles: nil]; [alterView show]; _canShake=NO; } }
相关文章推荐
- [iOS]判断文件编译是否开启ARC
- iOS技术点:判断用户是否开启推送开关/是否允许推送?
- 判断蓝牙和WiFi是否开启
- Android 虚拟机判断蓝牙是否开启
- IOS侦测蓝牙是否开启
- iOS开发判断是否开启摄像头权限
- 判断蓝牙WiFi是否开启 网上的
- iOS 判断当前APP是否开启定位服务,未开通点击确定进入设置里进行设置
- ios 判断用户是否开启权限---并跳转设置
- iOS如何判断应用是否开启摄像头权限
- ios判断是否开启了定位
- iOS技术点:判断用户是否开启推送开关/是否允许推送?
- iOS技术点:判断用户是否开启推送开关/是否允许推送?
- iOS 判断GPS是否开启
- iOS开发 判断用户是否开启了定位
- IOS 判断定位服务是否开启代码
- ios 判断用户是否开启定位权限并跳转设置
- iOS开发 判断用户是否开启了热点
- iOS-OC-监听蓝牙是否开启(打开状态)