埃迪斯通信标检测问题

这是我使用iPhone iOS 9检测Eddystone的代码:

- (void)viewDidLoad { [super viewDidLoad]; if ([CLLocationManager locationServicesEnabled]) { _locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.pausesLocationUpdatesAutomatically = NO; [self.locationManager requestAlwaysAuthorization]; NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"f7826da6-4fa2-4e98-8024-bc5b71e0893e"]; NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:bundleIdentifier]; self.locationManager.allowsBackgroundLocationUpdates = YES; [self.locationManager startMonitoringForRegion:beaconRegion]; [self.locationManager startRangingBeaconsInRegion:beaconRegion]; [self.locationManager startUpdatingLocation]; } else { NSLog(@"location service is disabled"); } } - (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(nonnull NSArray *)beacons inRegion:(nonnull CLBeaconRegion *)region { NSLog(@"beacons count: %lu", (unsigned long)[beacons count]); // beacons count always "0" } 

我还在plist NSLocationAlwaysUsageDescription字段中添加了。

问题是它无法检测到任何带有上述代码的Eddystone设备。 但对于第三方应用程序,它很好。

添加图像证明它是Eddystone信标

我做错了什么?

您的代码使用的是Core Location,它仅适用于iBeacon。 你将无法以这种方式发现Eddystone信标。

您需要使用一些与Eddystone兼容的SDK。 由于您似乎正在使用Kontakt.io的信标,您可能想要使用他们的SDK:

http://developer.kontakt.io/ios-sdk/quickstart/#eddystone-support

或者,您可以使用iOS的本机Core Bluetooth自行实施Eddystone扫描。 甚至还有一个关于如何做到这一点的例子,可在官方的Eddystone GitHub回购中找到:

https://github.com/google/eddystone/tree/master/tools/ios-eddystone-scanner-sample