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

  • 相关阅读:
    asp.net将word转成HTML
    asp.net 控件位置form验证
    javascript 正则表达式
    .net framework处理xml
    XMLHTTP与XMLDOC使用介绍(上)
    一个女程序员的征婚信息的select语句
    解决连接MySql4.0数据库出现的"character_set_results"问题
    javascript与cs代码互访
    杜绝<script src="js/tool.js" type="text/javascript"/>这样写的习惯
    总结:常用的正则表达式集合
  • 原文地址:https://www.cnblogs.com/sgdkg/p/5711977.html
Copyright © 2011-2022 走看看