Cannot keep BTLE running in background in Ionic 3

578 views Asked by At

Either I'm doing something wrong or the latest versions of iOS and Android no longer allow this functionality.

I am using (https://github.com/katzer/cordova-plugin-background-mode.git) in conjunction with the native BLE plugin for Ionic 3.

I need to maintain (or find and connect) to pair bluetooth devices in the background but it seems that iOS especially will severe the background BLE connection after a period of time (like 10-15 minutes). I know that iOS stops background activity after 10 minutes, but the katzer plugin is suppose to allow for BTLE processes to continue in the background.

Here is what I am trying to keep the BLE connection alive. I need to be able to connect or detect a disconnect from BLE so I can report in to my server the last known geolocation of the device.

 this.backgroundMode.enable();
    this.backgroundMode.on("activate").subscribe(() => {
      this.backgroundMode.disableWebViewOptimizations();

      console.log('backgroundMode activate');
      window.setTimeout(() => {
        this.bleLoop()
      }, 60000)
    });

Where bleLoop() is a function that does a scan for new devices to connect to.

Has ANYONE been able to get BLE working to connect to new devices or call the disconnect callback in the background using ionic 3?

0

There are 0 answers