Alex Stone
Alex Stone

Reputation: 47344

iBeacon - how to detect a time a user spends in a room or department?

I have an app that monitors or ranges iBeacons inside a building. How can I detect how long a user spends in a particular room?

I've observed that the proximity for a given beacon may jump from near to far, based on orientation of the device. This means that I cannot simply say that once the range is unknown, the visit is over. Should I continuously range a distance to a beacon and consider the visit to start/end once I detect X consecutive "near/unknown" states for a given beacon?

Upvotes: -1

Views: 211

Answers (1)

davidgyoung
davidgyoung

Reputation: 64961

There is no guarantee you will get any number of ranging callbacks with proximity "unknown" before a beacon disappears. Instead, you should use the monitoring APIs, and consider a room exited when you get a call to didExitRegion. Sometimes iOS will give you a spurious exit notification, so you need to protect against this. I do so by starting a timer on region exit, and I only perform the exit logic if I don't get a didEnterRegion callback within five seconds.

Of course, all this assumes that the "room" or "department" has beacons whose transmitter range end precisely at the edge of the room/department. Without very precise placement and control over transmitter power, this is unlikely to be exactly true. You have to decide if you can live with this approximation.

Upvotes: 1

Related Questions