涡流信标检测问题 [英] Eddystone beacon detecting issue

查看:107
本文介绍了涡流信标检测问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用来通过iPhone iOS 9检测Eddystone的代码:

Here is a code I use to detect Eddystone using iPhone iOS 9:

- (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<CLBeacon *> *)beacons
               inRegion:(nonnull CLBeaconRegion *)region
{
    NSLog(@"beacons count: %lu", (unsigned long)[beacons count]); // beacons count always "0"
}

我还添加了plist NSLocationAlwaysUsageDescription字段.

Also I added in plist NSLocationAlwaysUsageDescription field.

问题在于它无法检测到具有上述代码的任何Eddystone设备.但是使用第三方应用程序,效果很好.

The problem is that it can't detect any Eddystone device with code above. But with third party apps it finds well.

我做错了什么?

推荐答案

您的代码使用的是Core Location,仅适用于iBeacon.您将无法通过这种方式发现Eddystone信标.

Your code is using Core Location, which only works with iBeacon. You won't be able to discover Eddystone beacons this way.

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

You need to use some Eddystone-compatible SDK. Since you seem to be using Kontakt.io's beacons, you might want to use their SDK:

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

或者,您可以使用iOS的本机Core Bluetooth自己实施Eddystone扫描.甚至在官方Eddystone GitHub存储库中提供了有关如何执行此操作的示例:

Alternatively, you can use iOS's native Core Bluetooth to implement Eddystone scanning yourself. There's even an example on how to do that, available in the official Eddystone GitHub repo:

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

这篇关于涡流信标检测问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆