iBeacon技术笔记

#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{
//   
//}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值