iBeacon技术笔记
2015-06-05 15:50
337 查看
#pragma mark - CLLocationManagerDelegate
//剩下的就是通过CLLocationManagerDelegate中的各个方法来获取监控区域内的所有CLBeacon基站,进入或退出某个Beacon区域,计算举例某个CLBeacon的距离等。
/*startMonioringForRegion方法调用后,如果手机监测到进入或者离开一个iBeacon基站区域,delegate就会调用这两个方法
locationManager:didEnterRegion:
locationManager:didExitRegion:
*/
/*
然后可以在locationManager:didEnterRegion:方法中调用[_locationManager startRangingBeaconsInRegion:_ibeaconRegion];来开启Ranging模式。
当离开、进入一个iBeacon区域或者于基站距离发生变化时,location Manger就会调用didRangeBeacons:inRegion:方法
*/
//- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
//
// UILocalNotification *notification = [UILocalNotification new];
//
// // Notification details
// // notification.alertBody = [NSString stringWithFormat:@"Entered beacon region for UUID: %@",region.proximityUUID.UUIDString]; // Major and minor are not available at the monitoring stage
// // notification.alertAction = NSLocalizedString(@"View Details", nil);
// // notification.soundName = UILocalNotificationDefaultSoundName;
//
// notification.alertBody = @"Enter region notification";
// [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
//
// [self.beaconManager startRangingBeaconsInRegion:self.region];
//
//}
//该方法传递了两个参数,(NSArray *)beacons和(CLBeaconRegion *)region。这个beacons数组里的元素是按照距离排序的,所以取出数组中的第一个beacon就是离我们最近的那个ibeacons基站(当然这里也会有误差,不能保证真实距离就是最短的)
//- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
//
// if ([beacons count] > 0) {
//
// CLBeacon *nearestExhibit = [beacons firstObject];
// /*
// CLProximity 枚举:划分距离
// CLProximityUnknown,
// CLProximityImmediate,
// CLProximityNear,离iBeacon设备最近 10米左右
// CLProximityFar
//
// CLBeacons类中有如下几个属性:
// proximityUUID, major, minor, proximity, accuracy, rssi.
// 从远到近分别是CLProximityUnknown, CLProximityFar, CLProximityNear, CLProximityImmediate.
// accuracy(CLLocationAccuracy)表示以米为单位的精度
// rssi表示接受到的信号的强度
// */
// if (CLProximityNear == nearestExhibit.proximity) {
//
//
//
// } else {
//
//
//
// }
// // peripheralManagerDidUpdateStat
// // CBPeripheralManager
// }
//}
#pragma mark - Local notifications
#pragma mark - 本地通知
/*
UILocalNotification *notification = [UILocalNotification new];
notification.alertBody = @"Enter region notification";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
*/
//- (void)viewWillAppear:(BOOL)animated{
// [super viewWillAppear:animated];
//
// if (!peripheralManager)
// {
// peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
// }
// else
// {
// peripheralManager.delegate = self;
// }
//
//}
//#pragma mark - CBPeripheralManagerDelegate method
//- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
//
//}
//剩下的就是通过CLLocationManagerDelegate中的各个方法来获取监控区域内的所有CLBeacon基站,进入或退出某个Beacon区域,计算举例某个CLBeacon的距离等。
/*startMonioringForRegion方法调用后,如果手机监测到进入或者离开一个iBeacon基站区域,delegate就会调用这两个方法
locationManager:didEnterRegion:
locationManager:didExitRegion:
*/
/*
然后可以在locationManager:didEnterRegion:方法中调用[_locationManager startRangingBeaconsInRegion:_ibeaconRegion];来开启Ranging模式。
当离开、进入一个iBeacon区域或者于基站距离发生变化时,location Manger就会调用didRangeBeacons:inRegion:方法
*/
//- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
//
// UILocalNotification *notification = [UILocalNotification new];
//
// // Notification details
// // notification.alertBody = [NSString stringWithFormat:@"Entered beacon region for UUID: %@",region.proximityUUID.UUIDString]; // Major and minor are not available at the monitoring stage
// // notification.alertAction = NSLocalizedString(@"View Details", nil);
// // notification.soundName = UILocalNotificationDefaultSoundName;
//
// notification.alertBody = @"Enter region notification";
// [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
//
// [self.beaconManager startRangingBeaconsInRegion:self.region];
//
//}
//该方法传递了两个参数,(NSArray *)beacons和(CLBeaconRegion *)region。这个beacons数组里的元素是按照距离排序的,所以取出数组中的第一个beacon就是离我们最近的那个ibeacons基站(当然这里也会有误差,不能保证真实距离就是最短的)
//- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
//
// if ([beacons count] > 0) {
//
// CLBeacon *nearestExhibit = [beacons firstObject];
// /*
// CLProximity 枚举:划分距离
// CLProximityUnknown,
// CLProximityImmediate,
// CLProximityNear,离iBeacon设备最近 10米左右
// CLProximityFar
//
// CLBeacons类中有如下几个属性:
// proximityUUID, major, minor, proximity, accuracy, rssi.
// 从远到近分别是CLProximityUnknown, CLProximityFar, CLProximityNear, CLProximityImmediate.
// accuracy(CLLocationAccuracy)表示以米为单位的精度
// rssi表示接受到的信号的强度
// */
// if (CLProximityNear == nearestExhibit.proximity) {
//
//
//
// } else {
//
//
//
// }
// // peripheralManagerDidUpdateStat
// // CBPeripheralManager
// }
//}
#pragma mark - Local notifications
#pragma mark - 本地通知
/*
UILocalNotification *notification = [UILocalNotification new];
notification.alertBody = @"Enter region notification";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
*/
//- (void)viewWillAppear:(BOOL)animated{
// [super viewWillAppear:animated];
//
// if (!peripheralManager)
// {
// peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
// }
// else
// {
// peripheralManager.delegate = self;
// }
//
//}
//#pragma mark - CBPeripheralManagerDelegate method
//- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
//
//}
相关文章推荐
- 设计模式-单例模式
- 基于规则的分类
- oracle 锁的介绍 (转)
- AFNetworking2.0源码解析<一>
- operator和&operator
- Openwrt 串口密码登入
- jQuery File Upload 可运行的
- TypeError:’str’ does not support the buffer interface
- Spark MLlib Deep Learning Deep Belief Network (深度学习-深度信念网络)2.1
- 100万连接测试资料整理
- 小计C/C++问题(1)
- linux下打包zip文件
- boost::bind/boost::function
- 在Linux中修复“fatal error: x264.h: No such file or directo”错误的方法
- C# 中的委托和事件
- 关于springmvc引用json配置会报错的问题
- Android——ViewPager、PagerAdapter、Fragment(State)PagerAdapter的关系与区别
- 转:ASP.NET MVC 3 and App_Code folder
- 程序员的量化交易之路(27)--Cointrader之PriceData价格数据(14)
- intent.ACTION_SEND 发送邮件或者任何内容到邮件客户端或者qq 微信什么的