Estimote / iOS-Fleet-Management-SDK

Estimote Fleet Management SDK for iOS
https://developer.estimote.com
MIT License
1.18k stars 398 forks source link

Seem stopRangingBeaconsInRegion stop monitoring #192

Closed KevinJue closed 9 years ago

KevinJue commented 9 years ago

Problem/Question

The function stopRangingBeaconsInRegion seem to stop monitoring for a region. We can find in apple documentation

stopRangingBeaconsInRegion: Stops the delivery of notifications for the specified beacon region.

did you think it could also stop notification for monitoring or i'm doing something wrong ? this bellow code will let you reproduce.

-(void)setupEstimote {

    self.beaconManager = [[CLLocationManager alloc] init];
    self.beaconManager.delegate = self;
    [self.beaconManager requestAlwaysAuthorization];
    [self.beaconManager startUpdatingLocation];

    // Setup a new region with that UUID and same identifier as the broadcasting beacon
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"test"];
    self.beaconRegion.notifyEntryStateOnDisplay = YES;
    self.beaconRegion.notifyOnEntry = YES;
    self.beaconRegion.notifyOnExit = YES;

    [self.beaconManager startMonitoringForRegion:self.beaconRegion];
}

- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region {
    NSLog(@"didStartMonitoringForRegion");
    [self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
    NSLog(@"enter Region");
    [self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
    NSLog(@"Left Region");
    [self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion];
}

-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
    CLBeacon *beacon = [[CLBeacon alloc] init];
    beacon = [beacons lastObject];

    if (beacon.proximity == CLProximityImmediate) {
        NSLog(@"oh yeah i'm here");
        [self beaconNotification];
    } else {
        [self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion];
    }
}

Cheers

heypiotr commented 9 years ago

I see you're using Apple's Core Location API. This is an issues tracker for the Estimote SDK, so allow me to close this one. Can you post your problem on Estimote forums instead?

KevinJue commented 9 years ago

of course i can.

Just to know, if i'm using ESTBeaconManager instead of CLLocationManager, this issue will be fixed ?