Keep Bluetooth running on all pages of app

I’m using the BLE Plugin to connect to a heart rate monitor. I have a Bluetooth settings page where the connection takes place, and a subscription to incoming packets is established:

var count = 0;
BLE.startNotification(peripheral.id, scanInfo.service, scanInfo.heartrate).subscribe(buffer => {
    var data = new Uint8Array(buffer);
    content.innerHTML = data[1];
    count += 1;
    BluetoothPage.storage.set(count.toString(),data[1]);
});

But when you leave the Bluetooth page (it gets popped off with nav-pop) the data is no longer being stored because the subscription stops. I want it to continuously be recorded wherever the user is in the app. How can I do this?

I know this is 12 days old but perhaps I can point the next person in the right direction. In these circumstances you want to make use of a service (as a singleton). Services persist across components and are great for something like this or things like WebSockets. How to do that depends on if you’re using TypeScript or JS.

I did end up using a service, thanks for the response!

hi there, im having the same problem as you…would you mind to share your code on how you solve this problem? :relaxed: