【发布时间】:2014-11-23 08:57:42
【问题描述】:
我正在开发一个与硬件设备连接的BLE(bluetooth LE) 应用程序。
我能够发现并连接到设备,从设备读取数据,将数据写入设备。
我在 Apple 的 BLE 文档中找不到的是,当您靠近设备时,当应用程序关闭时,您如何获得通知。
我知道如何注册到characteristic 通知,但是这个通知只有在应用程序在后台时才会发生。
我知道iBeacon 可以在应用程序关闭时检测到蓝牙并发送通知,但我想在设备发现带有UUID 的某个 BLE 时收到通知。
iBeacon,正在使用带有 UUID 和 major and minor 字段的 BLE,我不需要/不想要。我只想注册一个来自 BLE 的某个UUID 的通知。
我这样做了,没有任何回应:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self initRegion];
- (void)initRegion
{
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"4AD3FADF-F179-4343-0000-000000000000"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"BLE-NAME"];
[self.locationManager startMonitoringForRegion:self.beaconRegion];
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
NSLog(@"ENTER");
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
NSLog(@"EXIT");
}
【问题讨论】:
标签: ios bluetooth bluetooth-lowenergy