问题描述
我要当有人进入上应用的iBeacon显示区域来创建一个订单
背景,但我有一个问题,当后台的应用程序。
I want to create a order when someone enters into the iBeacon region on appbackground,but I have a problem when the app on background.
我知道,如果用户打开的位置,蓝牙,进入区域,应用程序进入区域,用户打开蓝牙后,将检测ibeacon.But,应用程序无法接收输入的通知(有时工作),不能调用函数的LocationManager:(CLLocationManager *)经理didRangeBeacons:(NSArray的*)标inRegion:(CLBeaconRegion *)区域
这样的顺序不能创建
I know if user open "location" and "bluetooth" and enter into region, app will detect the ibeacon.But after entering into region, user open "bluetooth",the app can't receive the entry notification(sometime work) and can't invoke the functionlocationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
so the order can't be created.
没有人有这方面的经验?
Does anyone have experience on it?
推荐答案
有关更逼真,准确地获得蓝牙状态值,覆盖其委托给控制器。蓝牙核心架构将帮助这里得到准确的欲望。
For more realistic and accurately get bluetooth state value, override its delegate to controller. Core bluetooth framework will help here to get desire accuracy.
添加< CoreBluetooth / CoreBluetooth.h方式>
项目框架
使用方法
- (无效)peripheralManagerDidUpdateState:(CBPeripheralManager *)外设;
检查蓝牙通电?
外围Manager状态 的意志为您提供有关周边国家和相关代表的更多细节。
Peripheral Manager State will gives you more details about peripheral state and related delegates.
所以,当过设备已经打开它的蓝牙,上面的委托方法将被调用。
So when ever device has turn on it's bluetooth, above delegate method will be called.
在这里,您可以手动启动检查区域的更新。
And here you can manually start to check for region updates.
有关〔实施例:
_locationManager = [[CLLocationManager alloc] init];
[_locationManager setDelegate:self];
_beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:<Identifier>];
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
if (peripheral.state == CBPeripheralStateConnected) {
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
}
}
该方法 startRangingBeaconsInRegion
将调用方法:
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region;
这篇关于如何iBeacon显示在后台工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!