美文网首页唤起app
iOS下iBeacon总结

iOS下iBeacon总结

作者: Jun_Chen | 来源:发表于2017-06-13 17:26 被阅读0次

权限

要使用iBeacon监控,要先做以下检查

  • 检查设备是否支持Beacon扫描
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]) {
}
  • 必须获取Always定位权限
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedAlways) {
    [CLLocationManager requestAlwaysAuthorization];
}
  • 且必须打开后台获取地理位置更新权限

Important
Apps must have always authorization to use region monitoring, and they must be configured with the Location updates background mode to be launched.

Beacon属性

  • proximityUUID (The unique ID of the beacons being targeted.)
  • major (The value identifying a group of beacons.)
  • minor (The value identifying a specific beacon within a group.)

实现

一般先检测Beacon的进出(Enter/Exit),再获取具体距离(Ranging),且苹果建议只在Foreground情况下Ranging

CLBeaconRegion* region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:uuidStr];
region.notifyEntryStateOnDisplay = YES;
[locationManager startMonitoringForRegion:region];

// CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
    [manager startRangingBeaconsInRegion:(CLBeaconRegion *)region];
}

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
    [manager stopRangingBeaconsInRegion:(CLBeaconRegion *)region];
}

- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
}

关于后台运行

当App不在前台或者被杀死是,也可以感应iBeacon信号,系统会唤醒App并给予一小段时间(10秒左右)进行处理。
这时可以使用 [UIApplication beginBackgroundTaskWithExpirationHandler:] 请求更多后台执行时间

1个App最多能同时监控20个regions

Core Location limits to 20 the number of regions that may be simultaneously monitored by a single app.

相关文章

  • iOS下iBeacon总结

    权限 要使用iBeacon监控,要先做以下检查 检查设备是否支持Beacon扫描 必须获取Always定位权限 且...

  • iOS 中 iBeacon 开发

    iOS 中 iBeacon 开发 iOS 中 iBeacon 开发

  • 开发使用 iBeacon 的 iOS 7 应用

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

  • iBeacon的使用

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

  • iBeacon 应用实例

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

  • iBeacon相关知识

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

  • ibeacon

    总结 1.iOS 7.0及以后的版本开始支持iBeacon。2.硬件方面, iPhone4S 及以后, ipad ...

  • ibeacon 技术记录

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

  • iOS设备iBeacon扫描总结

    iBeacon是苹果公司提出的“一种可以让附近手持电子设备检测到的一种新的低功耗、低成本信号传送器”的一套可用于室...

  • IOS - ibeacon

    CLLocationManager CLBeaconRegion CLLocationManagerDelegat...

网友评论

    本文标题:iOS下iBeacon总结

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