I'm currently using the cordova-plugin-ble-central plugin in an Ionic 1 app. I'm converting this app to Ionic 2, so I want to use this plugin through ionic-native.
The issue is that some of the plugin's functions are not available through ionic-native. For example, the function ble.startStateNotifications(success, failure);
is not available with ionic-native, whereas ble.isEnabled(success, failure);
is (both are available in cordova-plugin-ble-central).
Do I have to use the plugin without ionic-native to be able to use all of it's methods?
==================
EDIT
Finally I used the plugin directly (outside ionic-native) and converted the callback functions to Observables like this :
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
declare var ble;
@Injectable()
export class BLEService {
constructor() {}
BLEstartStateNotifications() {
return new Observable((observer) => {
ble.startStateNotifications((state) => {
observer.next(state);
}, (err) => {
observer.error(err);
});
});
}
}
And then you can call the function as an Observable:
this.BLEstartStateNotifications().subscribe((state) => {
console.log(state);
}, (error) => {
console.log(error);
});