美文网首页
iOS -- ibeacon的相关知识

iOS -- ibeacon的相关知识

作者: Mn_Su | 来源:发表于2016-10-18 13:14 被阅读0次

第一.ibeacon的扫描实现

    1.导入头文件,调用代理和定义属性
        
            #import <CoreLocation/CoreLocation.h>

            <CLLocationManagerDelegate>
            
            @property (strong, nonatomic) CLBeaconRegion *myBeaconRegion;
            @property (strong, nonatomic) CLLocationManager *locationManager;

    2.配置info.plist相关参数
4BFBDBDF-699D-4FEF-B008-D05AE9FA1C60.png
    3.初始化相关变量

         self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
        
          //传入自己使用的ibeacon的UUID
        NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"e2c56db5-dffb-48d2-b060-d0f5a71096e0"];

        self.myBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
                                                                 identifier:@"com.appcoda.testregion"];
        
        [self.myBeaconRegion peripheralDataWithMeasuredPower:@-30];
        
        [_locationManager requestAlwaysAuthorization];

        [self.locationManager startMonitoringForRegion:self.myBeaconRegion];
        [self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];

    4.调用相关方法

        - (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion*)region
        {
            NSLog(@"开始。。。");
        //    [self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];
        }
        
        -(void)locationManager:(CLLocationManager*)manager didExitRegion:(CLRegion*)region
        {
            NSLog(@"结束。。。");
        //    [self.locationManager stopRangingBeaconsInRegion:self.myBeaconRegion];
        }
        
        
        -(void)locationManager:(CLLocationManager*)manager
               didRangeBeacons:(NSArray*)beacons
                      inRegion:(CLBeaconRegion*)region
        {
        //    CLBeacon *foundBeacon = [beacons firstObject];
            NSLog(@"-----------beacons: %@",beacons);
        //    NSLog(@"----------region: %@",region);
        //    NSLog(@"---------%@",manager);
            
        
        }
        
        
        
        
        - (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
        {
            NSLog(@"Failed monitoring region: %@", error);
        }
        
        - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
        {
            NSLog(@"Location manager failed: %@", error);
        }

第二.相关知识链接和demo实现

知识链接

相关文章

  • iOS -- ibeacon的相关知识

    第一.ibeacon的扫描实现 第二.相关知识链接和demo实现 知识链接

  • iBeacon相关知识

    从iBeacon开始 入门iBeacon概述 在iOS 7中引入的iBeacon是一项令人兴奋的技术,可以实现新的...

  • iOS 中 iBeacon 开发

    iOS 中 iBeacon 开发 iOS 中 iBeacon 开发

  • 开发使用 iBeacon 的 iOS 7 应用

    开发使用 iBeacon 的 iOS 7 应用 开发使用 iBeacon 的 iOS 7 应用

  • iBeacon 应用实例

    iBeacon是什么?     苹果官方对iBeacon的描述:iBeacon是iOS 7推出的一项技术,可为AP...

  • ibeacon 技术记录

    ibeacon是苹果公司在ios7发布的一款硬件,可以感知ibeacon的位置。ibeacon 只是一个硬件设备,...

  • iBeacon相关总结

    创建iBeacon对象 指定是否在边界穿越事件中通知给App 如果在边界穿越情况发生时,app没有在后台启动,系统...

  • iBeacon的使用

    听说可以通过iBeacon激活IOS App,便研究了一下。 一、基本原理 iBeacon一般用于外设的,外设加入...

  • IOS - ibeacon

    CLLocationManager CLBeaconRegion CLLocationManagerDelegat...

  • iBeacon开发学习资料整理

    开发使用 iBeacon 的 iOS 7 应用:http://www.cocoachina.com/industr...

网友评论

      本文标题:iOS -- ibeacon的相关知识

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