I am intending to use Proximity Beacons to detect when a customer who has my Android app enters a location that contains a beacon. The app will push a notification to their device once a beacon is detected.
As far as I can tell on Android 8.0+, the only way to do this is to use the
.withScannerInForegroundService, which runs the scan in the foreground and forces an ongoing notification to the user. Since I want to always be scanning for beacons, this isn’t ideal as it drains battery power and annoys the user.
The solution I’ve come up with is to schedule a job that does a 5 second scan every 15 minutes, and if it detects a beacon in that time it pushes the notification. This would be a lot less annoying to the user, however it relies on the user being within the beacon’s range for a maximum 15 minutes to guarantee they’ll get the notification, so it isn’t ideal. A lot of customers will simply pass by a beacon at the entrance to a facility and won’t linger for nearly 15 minutes.
Is this the best solution to solve my problem? Has anyone figure out a different approach?
Another solution I’ve thought of is using GeoFencing to determine if the user is near a location with a beacon, and if so just turn on beacon scanning when they enter and run continuously until they exit.