Estimote iBeacons не обнаруживает

Я недавно купил 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.
}

// Метод делегата возвращает состояние региона НЕИЗВЕСТНО!!!

-(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.

1 ответ

Решение

Просто добавьте еще одну строку в нижней части вашего viewDidLoad метод:

 [self.locationManager startMonitoringBeaconsInRegion:self.beacon region];
Другие вопросы по тегам