I have a React Native application and I am reading accelerometer data each 20ms using the react-native-sensor-manager package.
I start the listener and log it into Reactotron each time it reads data, each 20ms
SensorManager.startAccelerometer(20)
DeviceEventEmitter.addListener('Accelerometer', function (data) {
console.tron.warn(data)
})
It works well if I leave the application in foreground, and even in background, but if I lock the phone it stops reading data. It also stops if I kill the app from the task manager.
How can I achieve to read data even in background?