BLE plugin not finding devices with scan()

I’m using the Cordova BLE Plugin and have been testing on Android 5.1.1 and 6+ devices. BLE.enable() seems to work just fine so I know the plugin works, but BLE.scan() is giving me trouble. Here’s the code I have (which is based off of this example):

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

  templateUrl: 'build/pages/bluetooth/bluetooth.html'
export class BluetoothPage {

  constructor() {}

  scan() {
      var foundDevice;
      var bleApp = {

          init: function() {
              statusDiv.innerHTML = "Initializing";
              document.addEventListener('deviceready', this.startScan, false);
              console.log("Operations completed");

          startScan: function() {
              foundDevice = false;
              statusDiv.innerHTML = "Scanning";

              function scanFailure(reason) {
                  statusDiv.innerHTML = "Scan error";
                  alert("Scan Failed");

              function scanSuccess(peripheral) {
                  foundDevice = true;
                  statusDiv.innerHTML = "Found device";
                  alert("Device Found");

              BLE.scan([], 25, scanSuccess, scanFailure);

              setTimeout(function() {
                  if (!foundDevice) {
                      statusDiv.innerHTML = "No device found";
              }, 25000);

And then a button will simply call scan(). There are no errors with building this, and although the HTML will change text and time out after 25 seconds, it never finds a device (meaning no alert ever appears). My location data is on as well. Any advice?

EDIT: I’m becoming more confused. If I change the success and failure calls in BLE.scan() to just be simple alerts, they are both called one after the other no matter what. Even with Bluetooth off.


Hi Ursi,

I was experiencing this same issue and came to the conclusion that the Bluetooth LE scan seems to ONLY pick up Bluetooth LE devices. For instance, it would not pick up other phones or computers that were discoverable with bluetooth enabled; it only found my one Ada Bluefruit LE device. I didn’t see a standard Bluetooth native component option, so I’m not sure if this is the expected behavior of the Bluetooth LE native component, or if there’s something we’re both missing.

Here’s my typescript code for reference:

BLE.scan([], 60).subscribe(
device => {
console.log("Found device: " + JSON.stringify(device));
err => {
console.log("Error occurred during BLE scan: " + JSON.stringify(err));
() => {
console.log(“End of devices…”);

Hopefully that’s of some help.

1 Like

Were you able to use its counterpart, the peripheral mode on ionic?