Skip to content

Commit

Permalink
Don't try to turn on Ranging if region cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbonnes committed Jun 27, 2014
1 parent bde7c6a commit 7896300
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Classes/OrgBeuckmanTibeaconsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)
nil];

if (_autoRange) {
[self turnOnRangingWithRegion:[self.monitoringRegions objectForKey:region.identifier]];
CLBeaconRegion *beaconRegion = [self.monitoringRegions objectForKey:region.identifier];
if (beaconRegion) {
[self turnOnRangingWithRegion:beaconRegion];
} else {
NSLog(@"[INFO] Cannot find beaconRegion to range");
}
}

[self fireEvent:@"enteredRegion" withObject:event];
Expand Down Expand Up @@ -296,6 +301,11 @@ - (void)turnOnRangingWithRegion:(CLBeaconRegion *)beaconRegion
return;
}

if (beaconRegion == nil) {
NSLog(@"[ERROR] Unable to find beaconRegion for beaconRegion");
return;
}

[self.rangingRegions setObject:beaconRegion forKey:beaconRegion.identifier];

[self.locationManager startRangingBeaconsInRegion:beaconRegion];
Expand Down

0 comments on commit 7896300

Please sign in to comment.