Search code examples
androidibeaconibeacon-android

Why android Ibeacon need bluetooth permission?


I am using the android (org.altbeacon:android-beacon-library:2.19.3) library providing APIs to interact with Beacons

It has required Location & Bluetooth permission.

Permission Requirements:

https://altbeacon.github.io/android-beacon-library/requesting_permission.html

IOS's ibeacon does not require Bluetooth permission, why does android ibeacon need Bluetooth permission?

is there any alternate library for android Ibeacon


Solution

  • Yes, Android requires Bluetooth permission to scan for bluetooth beacons but iOS does not require the same permission to detect iBeacon. The requirement for Android to have Bluetooth permission to scan for beacons is true regardless of the library you use. It is an OS platform restriction.

    enter image description here

    The reason why Android requires this permission and iOS does not is based on history of how the two platforms evolved. A few points:

    • Starting with iOS 7, Bluetooth beacons support was added to the CoreLocation API, which used the Location permission, not individual permissions for various sensors like GPS, WiFi, cellular radio, and Bluetooth, all of which can be used for location purposes. Apple clearly made a design decision to put all of the sensors behind a single permission.

    • Open Source Android has no built-in APIs for detecting beacons at all -- it only has Bluetooth APIs. (Beacon APIs are offered by the Google Play Services add on or the open source Android Beacon Library). So it makes sense that when Bluetooth LE scanning was added in Android 4.3, it was treated as something that must be behind the Bluetooth permission.. These APIs happened to work with Apple's iBeacon invention, but the APIs were not designed for location.

    • When Android added runtime permissions in Android 6, it tried to protect the privacy of users by making the Location permission a runtime permission, and further, it put Bluetooth scanning behind this same location permission in addition to the Bluetooth permission in an attempt to protect privacy.

    • On iOS, the Bluetooth LE APIs do require Bluetooth permission, and Apple sandboxed the Bluetooth functionality from iBeacon. In this way, detecting iBeacon must obtain Location permission and does not require Bluetooth permission. On the other side of the coin, non-iBeacon detection is possible with regular Bluetooth permission but Apple filters out any packets that match iBeacon. Android has no equivalent sandboxing, which is one reason both permissions are required.

    One important thing to note: Apple not needing Bluetooth permission to detect beacons only applies to the iBeacon format. If you try to detect AltBeacon or Eddystone you actually do need the Bluetooth permission (and not the Location permission for those formats.) This is a "loophole" that is useful for avoiding extra permissions in some cases on iOS devices.

    One final note: Starting with Android 12, there is a new BLUETOOTH_SCAN permission that you can use instead of location permission. The idea is to make it so Android no longer requires location permission to scan for regular Bluetooth devices. But there is a big catch: to use this new permission, you must declare in your AndroidManifest.xml that your app does not use Bluetooth for location purposes (e.g. beacons) and Android says it will filter out some scan results in these cases. They don't say explicitly, but that probably means they will filter out any Bluetooth packet matching a known beacon format like iBeacon, AltBeacon or Eddystone.