Distance of iPhone from Beacon

Hello,
I am working on an app that displays notification when user enters a particular area and exits from the area.
I am using 3 beacons for my app. When user is in between second and third Beacon I need to notify the user that he is inside the premises and when user has crossed the first beacon I need to notify him that he is outside the premises.
Till some extent I am able to achieve this by using the beacons accuracy property as distance between the user’s device and all three beacons, but the time to display an alert to the user is more about 30 sec to one minute, but it should be instant.

@praneti

I recommend you to get familiar with the monitoring characteristics. You can read more about it here.

In your case I suggest to create 2 regions. First region consisting of the second and third beacon and second region consisting of first beacon. Whenever the user will be in range of the first region he will receive notification of being inside your premises. When entering the second region, he will be notified that he exited the premises. Both notifications should be based on ‘beaconManager:didEnterRegion’ method. Thanks to that you will get rid of the 30 sec delay which is purposefully implemented for ‘beaconManager:didExitRegion’ to make sure you won’t receive false notifications. Please remember I am not familiar with the exact positioning of your beacons and this is crucial in case of perfecting the user experience.

Hi Jacku
I have tried registering two beacon regions as:

CLBeaconRegion *enterRegion = [[CLBeaconRegion alloc] initWithProximityUUID: [[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"] identifier:@"com.myCompanyName.BeaconDemoEntry"];
enterRegion.notifyOnExit = true;
enterRegion.notifyOnEntry = true;
[_coreLocation startMonitoringForRegion:enterRegion];
[_coreLocation startRangingBeaconsInRegion:enterRegion];
enterRegion.notifyEntryStateOnDisplay = true;
   
CLBeaconRegion *exitRegion = [[CLBeaconRegion alloc] initWithProximityUUID: [[NSUUID alloc] initWithUUIDString:@"4E1AC0BA-AF2E-402E-9701-C17F041C0865"] major:2 identifier:@"com.myCompanyName.BeaconDemoExit" ];

exitRegion.notifyOnExit = true;
exitRegion.notifyOnEntry = true;
[_coreLocation startMonitoringForRegion:exitRegion];
[_coreLocation startRangingBeaconsInRegion:exitRegion];
exitRegion.notifyEntryStateOnDisplay = true;

But in didRangeBeacon I am getting only one beacon that is in region last registered (in his case with region identifier “com.myCompanyName.BeaconDemoExit”)

Same UUID (4E1AC0BA-AF2E-402E-9701-C17F041C0865) is set to my beacon kept in at exit point.

What is wrong that I am doing here because of which I am not getting beacon in my entry region.

Also, if I create two beacon regions can I get the distance between users device and all 3 beacons? I need to display notification when user is outside the premises and didEnterRegion will be called as soon as user enters the beacon region that can also be possible when user is moving from inside the bank to outside and so the alert will be displayed when user is still in the bank.

As I wrote previously, I do not know the exact positioning of the beacons. Your previous description suggested a different setting. In this case I do suggest to stick to one region for the whole space. Whenever the user enters the range of any of the 3 beacons he will be notified about being in your premises. When his phone does not receive signal from any of the beacons for 30 seconds he will be notified that he left your premises.

This is because Core Location will call your didRangeBeacons delegate once per each region that you’re ranging beacons in. If you switch to Estimote SDK instead, you can set returnAllRangedBeaconsAtOnce property of the ESTBeaconManager to true, and you’ll then get a single call to didRangeBeacons with results for both of your regions.