BLE plugin not working on Ionic


#1

Hi everyone!

I’m trying to implement beacon reading functionality in a Ionic 2 application with TS as a language, but I cannot get any response or error from the BLE.

I’m using Ionic Native and previously installed cordova-plugin-ble-central, but at the moment of using it I haven’t any response…

this is my code:

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

@Page({
  templateUrl: 'build/pages/beacons/beacons.html'
})
export class beaconsPage {
  beaconList: any;
  error: string;
  message: string;

  constructor(private platform: Platform) {
    this.platform = platform;
    this.platform.ready().then(() => {
      BLE.startScan([]).subscribe(device => {
        this.beaconList = device;
        this.message = "Success" + JSON.stringify(device);
      },
        err => {
          this.error = err.error;
          this.message = "Error";
        });

    });
  }
}

Thanks in advance!

Carlos


#2

Try calling BLE.enable() after platform.ready()


#3

Thanks!

We are start using the IBeacon Ionic Native component and it looks promising