首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Eddystone信标探测问题

Eddystone信标探测问题
EN

Stack Overflow用户
提问于 2015-12-12 14:08:00
回答 1查看 1.4K关注 0票数 3

下面是使用iPhone iOS 9检测Eddystone的代码:

代码语言:javascript
运行
复制
- (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字段。

问题是,上面的代码无法检测到任何Eddystone设备。但有了第三方应用程序,它找到了很好的服务。

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-14 13:45:34

您的代码使用的是,它只适用于iBeacon。你不可能这样发现埃迪斯通的信标。

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

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

或者,您可以使用iOS的本机核心蓝牙来实现Eddystone自己扫描。甚至还有一个关于如何做到这一点的例子,可以在官方的Eddystone GitHub回购中获得:

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34240751

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档