zoukankan      html  css  js  c++  java
  • ibecon后台运行


    程序被硬关闭后,只能执行这三个回调,而且必须写在appdelegate中,退出ibeacons信息区域时会有延时10秒左右,进入时无延时

    - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region;
    - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;
    - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region ;
    程序被硬关闭后,不能执行回调,之前就是犯错误在这了 
    - (void)locationManager:(CLLocationManager *)manager
            didRangeBeacons:(NSArray *)beacons
                   inRegion:(CLBeaconRegion *)region;

    appdelegate中这样声明即可:
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.delegate = self;



    然后在页面中启动检测ibeacons信息位置:
        NSUUID *proximityUUID = [[NSUUID alloc] initWithUUIDString:kUUID];
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID identifier:kIdentifier];
        self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.activityType = CLActivityTypeFitness;
    self.locationManager.distanceFilter = kCLDistanceFilterNone;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    //搜索附近ibeacons

        [self.locationManager startMonitoringForRegion:self.beaconRegion];
        [self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
        [self.locationManager requestStateForRegion:self.beaconRegion];
    然后在plist文件中添加Required background modes选项,增加三个值
    App communicates using CoreBluetooth,App shares data using CoreBluetooth,App registers for location updates
    然后就可以自己玩了。详尽参考apple的demo-airlocate
    附链接https://github.com/linlinqi/AirLocate

  • 相关阅读:
    OSX 10.8+下开启Web 共享 的方法
    OSX 10.8+下开启Web 共享 的方法
    OSX 10.8+下开启Web 共享 的方法
    ★如何解释特修斯之船问题?
    ★如何解释特修斯之船问题?
    ★如何解释特修斯之船问题?
    JS中event.keyCode用法及keyCode对照表
    JS中event.keyCode用法及keyCode对照表
    JS中event.keyCode用法及keyCode对照表
    用webgl打造自己的3D迷宫游戏
  • 原文地址:https://www.cnblogs.com/sgdkg/p/5711977.html
Copyright © 2011-2022 走看看