The best way for my app? (Ranging or Monitoring)


I’m creating an App which lets users in a room control lights and temperature. This would only work if a user is the room so when it’s in range of the beacon placed in the room. I’ve also made an indoor location for this, the room looks like this (dunno why it didn’t made a door in the room but it’s at the top right corner)

Let’s say the beacon I use is the Bottom blueberry beacon, what would be the best way to know it the user is in the room (Monitoring or Ranging)?

I tried ranging in the Appdelegate of my App, so when the user is in range of the beacon is shows the controls for controlling the lights and temperature. When the user is outside (± 3 meters from the door) the screen pops back saying that the user is not in range. But this isn’t really stable as sometimes it justs pops back saying the user isn’t in the room while he is.

Any ideas?

My code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

revealController = (SWRevealViewController *) self.window.rootViewController;
revealController.rearViewRevealWidth = self.window.bounds.size.width - 40;

//Set navigationbar colors
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.545 green:0.200 blue:0.776 alpha:1.000]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setOpaque:NO];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
                                                      [UIFont fontWithName:@"" size:24.0f],

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

//Setup first screen
UIStoryboard *main = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
nbvc = [main instantiateViewControllerWithIdentifier:@"NotInRange"];
self.window.rootViewController = nbvc;

//Setup ranging beacons
self.beaconManager = [ESTBeaconManager new];
self.beaconManager.delegate = self;
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"] identifier:@"Ranged region"];
[self.beaconManager requestAlwaysAuthorization];

return YES; }

- (void)applicationDidEnterBackground:(UIApplication *)application {
[self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion]; }

- (void)applicationDidBecomeActive:(UIApplication *)application {
[self.beaconManager startRangingBeaconsInRegion:self.beaconRegion]; }

-(void)beaconManager:(id)manager didRangeBeacons:(NSArray<CLBeacon *> *)beacons inRegion:(CLBeaconRegion *)region{  CLBeacon *nearestBeacon = beacons.firstObject;

    if([nearestBeacon proximity] == CLProximityNear || [nearestBeacon proximity] == CLProximityImmediate)
        self.window.rootViewController = revealController;
        self.window.rootViewController = nbvc;
    self.window.rootViewController = nbvc;

Hmm I’ve changed the signal strength of one of the beacons to Weak, but still I can turn the room’s light when i’m 3/4 meters out of the room. I also added all the beacons I have placed in the room, so i’m now ranging a total of 6 beacons. This helps a lot (no signal loss anymore). So that seems to help, still i’m not sure what would be the best way of knowing when a user left the room or enters the room.