Search code examples
iosibeaconestimote

How to add condition in didExitRegion when all the Estimotes in the area cannot be detected


Here is our scenario:

We plan to setup around 4 beacons in huge room (i.e. like a department store). Once the user goes in the room, the application will notify the user, "Welcome to our shop!". When the user leaves the room, the application will then notify the user, "Please come again!". The reason why we plan to place 4 beacons is that to make sure that while the beacons are in range with the device, we can make sure that the user is really still in the room. (Our worry is the user might still be in the room and the notification for saying "Please come again!" appears.)

We would like to know if it is possible to code that if the mobile device could not scan for all the beacons, the user has already left the regions and the device will send a local notification.


Solution

  • In order for this to work you need to:

    1. Make sure you have full coverage of the store with the radio range of your beacons.
    2. Set the identifiers on the beacons so they share a ProximityUUID.
    3. Define a region that matches all the beacons (e.g. the region should define the ProximityUUID and leave the major and minor null).
    4. Monitor for this region.
    5. In the didExitRegion callback, start a three second timer that only sends the exit notification if you do not get a didEnterRegion callback in this period. This is needed because iOS sometimes sends a spurious exit event followed by an enter event a second later.
    6. If the timer goes off without an enter event, only then send the exit local notification.