// If location permission is denied, you'll end up here
scanError(error) {
this.setStatus('Error ' + error);
// let toast = this.toastCtrl.create({
// message: 'Error scanning for Bluetooth low energy devices',
// position: 'middle',
// duration: 5000
// });
// toast.present();
}
@tearforfear007 Thanks for this,
Subscribe is not triggering in scan function. can any body help me on this. Using Angular 7 and ionic 4 Kindly find the below code
import { Component, NgZone } from '@angular/core'; import { BLE } from '@ionic-native/ble/ngx'; import { Observable } from "rxjs" // import { NavController } from 'ionic-angular'; // import { ToastController } from 'ionic-angular';
@Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage {
devices: any[] = []; statusMessage: string;
constructor( // public navCtrl: NavController, // private toastCtrl: ToastController, private ble: BLE, private ngZone: NgZone) { }
ionViewDidEnter() { console.log('ionViewDidEnter'); this.scan(); }
}
scan() { this.setStatus('Scanning for Bluetooth LE Devices'); this.devices = []; // clear list
}
// If location permission is denied, you'll end up here scanError(error) { this.setStatus('Error ' + error); // let toast = this.toastCtrl.create({ // message: 'Error scanning for Bluetooth low energy devices', // position: 'middle', // duration: 5000 // }); // toast.present(); }
setStatus(message) { console.log(message); this.ngZone.run(() => { this.statusMessage = message; }); }
}