Mit Bluetooth helfen auf, aber die Lage aus, können Sie Leuchtfeuer Bluetooth LE-Geräte nur mit CoreBluetooth
APIs erkennen und nicht mit CoreLocation
APIs.
Dies verhindert effektiv, dass Sie iBeacon-Übertragungen erkennen, da iOS ihre Erkennung über CoreBluetooth
blockiert. Siehe meinen Blogbeitrag hier: http://developer.radiusnetworks.com/2013/10/21/corebluetooth-doesnt-let-you-see-ibeacons.html
Sie können jedoch CoreBluetooth
verwenden, um andere Beacon-Formate wie AltBeacon und Eddystone zu erkennen. Ich habe Open-Source-Code, der zeigt, wie man das mit iOS beacon tools macht.
die Werkzeuge über Verwendung, hier ist ein Beispiel für Scannen für AltBeacon, Eddystone-UID, Eddystone-URL und Eddystone-EID und Protokollierung der Kennungen erkannt:
self.beaconParsers = [[NSMutableArray alloc] init];
RNLBeaconParser *altBeaconParser = [[RNLBeaconParser alloc] init];
[altBeaconParser setBeaconLayout:@"m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25" error: Nil ];
RNLBeaconParser *uidBeaconParser = [[RNLBeaconParser alloc] init];
[uidBeaconParser setBeaconLayout:@"s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19" error: Nil];
RNLBeaconParser *urlBeaconParser = [[RNLBeaconParser alloc] init];
[urlBeaconParser setBeaconLayout:@"s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v" error: Nil];
RNLBeaconParser *eidBeaconParser = [[RNLBeaconParser alloc] init];
[eidBeaconParser setBeaconLayout:@"s:0-1=feaa,m:2-2=30,p:3-3:-41,i:4-11" error: Nil];
self.beaconParsers = @[ altBeaconParser, uidBeaconParser, urlBeaconParser, eidBeaconParser ];
self.cbManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()
options:@{ CBCentralManagerOptionRestoreIdentifierKey:
@"myCentralManagerIdentifier" }];
...
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if (central.state == CBCentralManagerStatePoweredOn && self.scanning) {
CBUUID *eddystone16BitUUID = [CBUUID UUIDWithString:@"FEAA"];
NSLog(@"eddy uuid is %@", [eddystone16BitUUID UUIDString]);
[self.cbManager scanForPeripheralsWithServices:@[eddystone16BitUUID] options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @(YES)}];
// this scans for BLE peripherals including beacons
[self.cbManager scanForPeripheralsWithServices:nil options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @(YES)}];
}
else {
if (central.state == CBCentralManagerStateUnknown) {
NSLog(@"CoreBluetooth state UNKNOWN");
}
else if (central.state == CBCentralManagerStateResetting) {
NSLog(@"CoreBluetooth state RESETTING");
}
else if (central.state == CBCentralManagerStateUnsupported) {
NSLog(@"CoreBluetooth state UNSUPPORTED");
}
else if (central.state == CBCentralManagerStateUnauthorized) {
NSLog(@"CoreBluetooth state UNAUTHORIZED");
}
else if (central.state == CBCentralManagerStatePoweredOff) {
NSLog(@"CoreBluetooth state POWERED OFF");
}
}
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
NSDictionary *serviceData = advertisementData[@"kCBAdvDataServiceData"];
RNLBeacon *beacon = Nil;
NSData *adData = advertisementData[@"kCBAdvDataManufacturerData"];
for (RNLBeaconParser *beaconParser in self.beaconParsers) {
if (adData) {
beacon = [beaconParser fromScanData: adData withRssi: RSSI forDevice: peripheral serviceUuid: Nil];
beacon.bluetoothIdentifier = [peripheral.identifier UUIDString];
}
else if (serviceData != Nil) {
for (NSObject *key in serviceData.allKeys) {
NSString *uuidString = [(CBUUID *) key UUIDString];
NSScanner* scanner = [NSScanner scannerWithString: uuidString];
unsigned long long uuidLongLong;
[scanner scanHexLongLong: &uuidLongLong];
NSNumber *uuidNumber = [NSNumber numberWithLongLong:uuidLongLong];
NSData *adServiceData = [serviceData objectForKey:key];
if (adServiceData) {
beacon = [beaconParser fromScanData: adServiceData withRssi: RSSI forDevice: peripheral serviceUuid: uuidNumber];
}
}
}
if (beacon != Nil) {
break;
}
}
if (beacon != Nil) {
NSString *key = [NSString stringWithFormat:@"%@ %@ %@", beacon.id1, beacon.id2, beacon.id3];
NSLog(@"Detected beacon: %@", key);
}
Ja, Sie können tun, denke ich. –