[SOLVED] Issues with BLE and Android 6


Hi, I’m testing an application that scans for beacons. It works fine on the Sony Xperia Z1 and the Xiaomi Mi2 running Android 5, but on my Z2 (which is on Android 6) it doesn’t seem to work. Here is the code I’m using:

import {Toast, Page, NavController} from 'ionic-angular';
import {BLE} from 'ionic-native';

  templateUrl: 'build/pages/beacons/beacons.html',

export class Beacons {
    constructor(public nav: NavController) {}

    beaconMagic() {
        BLE.isEnabled().then(data => {

            BLE.scan([], 10).subscribe(data => {

                let toast = Toast.create({
                    message: String(data.rssi) + ", " + String(data.id),
                    duration: 9000,
                    showCloseButton: true,


I’ve tested with the alert in different places in the beaconMagic() function (of course not with the data.rssi and data.id, but with a dummy string). The function is executed when clicking on a button on the page. The alert shows up when placed before the isEnabled() and before the scan(). When the toast is in the subscribe() (as seen in the code above), it doesn’t show up at all on Android 6, however. On Android 5 it shows the rssi and id properly.

Could this be an issue with the permission system introduced in 6 or is there something I’m missing?

EDIT: Forgot to mention that I did get an alert requesting a permission, namely the location one.

EDIT 2: Found out what was causing the issue thanks to this SO question: http://stackoverflow.com/questions/33045581/location-needs-to-be-enabled-for-bluetooth-low-energy-scanning-on-android-6-0

Basically, you need to grant the permission for the location services and then turn on both Bluetooth and Location. Annoying that you have to turn both on (RIP battery), but it works.