Android / iOS - BLE - wake up a terminated applica

2020-07-30 03:02发布

问题:

Iam creating an iOS and an Android application that read some data from a bluetooth sensor and saves them in a db.

I want to give the ability to save the sensor's data even when the application is terminated.

fyi. I have already managed to read the sensor in both iOS and Android while the app is the background.

But my concern is on how to make the following scenario work:

-Sensor is disconnected from the phone -User terminates the application from the task manager -User connects (and pairs) the BLE sensor to the device -The application wakes-up in the background and reads the sensor's output and then goes back to sleep.

Any suggestions?

回答1:

For iOS this is possible as described in Apple doc Core Bluetooth Background Processing for iOS Apps.

For Android you could start a Service (by your app and also on device boot) and (re)connect to the device.

Also you could post a local notification in iOS/Android background Service - and when the user touches it, start the BLE app.