【问题标题】:Estimote iBeacons not detecting估计 iBeacons 未检测到
【发布时间】:2014-06-02 10:25:41
【问题描述】:

我最近购买了我看过很多演示但无法检测到设备的 estimote。

这是我的代码

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self
                                                                     queue:nil
                                                                   options:nil];


    //Set location managaer delegate
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;


   NSUUID* uuid = [[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];

    // Setup a new region with that UUID and same identifier as the broadcasting beacon
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"testRegion"];
    self.beaconRegion.notifyEntryStateOnDisplay = YES;
    self.beaconRegion.notifyOnEntry = YES;
    self.beaconRegion.notifyOnExit = YES;
 [self.locationManager startMonitoringForRegion:self.beaconRegion];
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
    // Do any additional setup after loading the view, typically from a nib.
}

// 委托方法返回区域状态UNKNOWN!!!

-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{

    switch (state) {
        case CLRegionStateInside:
            currentBeconRegion = (CLBeaconRegion *)region;
            [self.locationManager startRangingBeaconsInRegion:currentBeconRegion];
            NSLog(@"INSIDE the Region");
            break;
        case CLRegionStateOutside:
            NSLog(@"OUTSIDE the Region");
            break;
        case CLRegionStateUnknown:
        default:
            NSLog(@"Region state UNKNOWN!!!");
            [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
            break;
    }
}

// 输入区域

    -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    //check if we're ranging the correct beacon
    if (![self.beaconRegion isEqual:region]) { return;}

    NSLog(@"didEnterRegion");
    if([region isKindOfClass:[CLBeaconRegion class]])
    {
        currentBeconRegion = (CLBeaconRegion *)region;
        if ([beaconRegion.identifier isEqualToString:@"testRegion"])
        {

            //send local notificaation
            UILocalNotification *notice = [[UILocalNotification alloc] init];
            notice.alertBody = @"Becoan Found!!!";
            notice.alertAction =@"View";
            [[UIApplication sharedApplication] presentLocalNotificationNow:notice];

            //srart raning beacon region
            [self.locationManager startRangingBeaconsInRegion:currentBeconRegion];


        }
    }

}

我错过了什么?我如何更改 ProximityUUID。

【问题讨论】:

  • 哇,你刚刚完全改变了你的代码哈哈......你在你的代码中从哪里开始你的测距和/或监控?
  • 是的,因为我检查了 didDetermineState 方法,它总是说 Region state UNKNOWN!!!。是的,我正在监控。
  • 我在问你的代码是从哪里开始测距和/或监控的。您需要发布更多代码。
  • 请参阅此检查案例 CLRegionStateInside 中的方法 didDetermineState:因为我正在使用 startRangingBeaconsInRegion。我不知道监控的代码。我想检测 iBeacon 是否在该区域内
  • 您的代码在每次编辑时都变得越来越复杂......为什么在多种方法中打开和关闭多行?而且,根据这个网站joris.kluivers.nl/blog/2013/09/27/playing-with-ibeacon,您的 UUID 是正确的(它是所有 Estimote 设备的 UUID)并且目前无法更改。

标签: ios objective-c ibeacon estimote


【解决方案1】:

只需在 viewDidLoad 方法的底部再添加一行:

 [self.locationManager startMonitoringBeaconsInRegion:self.beacon region];

【讨论】:

  • 我已经把那行放在了“didEnterRegion”、“didRangeBeacons”、“didExitRegion”上。没有这个方法调用。只有 didDetermineState 第一次被调用了两次“Region state UNKNOWN!!!”第二次“区域外”
  • 我对所有设备都相同的 ProximityUUID 有一个疑问?
  • 是的,您的变送器的 ProximityUUID 必须与您用于监控的 ProximityUUID 匹配 (B9407F30-F5F8-466E-AFF9-25556B57FE6D) 否则您将获得如您所描述的结果。您可以使用 iBeacon Locate for Android 或 ScanBracon for Mac 等工具来读取 iBeacon 标识符,而无需预先知道它们,但 iOS 不允许您这样做。
  • 我的手机附近有 estimote 设备。如果我使用 B9407F30-F5F8-466E-AFF9-25556B57FE6D 作为 ProximityUUID 它没有检测到。那么我怎么知道真正的 ProximityUUID。我的问题是我想检测我的设备是否靠近估计设备。我已经完成了上面的代码。我没有得到结果意味着它可能是 ProximityUUID 问题,但我无法找到如何为 estimote 设备找到它。请帮忙,我真的很挣扎
  • 如何获取我的 estimote 设备的 ProximityUUID?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-22
  • 2016-01-30
  • 2011-10-30
相关资源
最近更新 更多