I have a React Native application that is reading accelerometer data every 2 seconds using the expo-sensor package. My goal is to run this in the background.
The app works fine in the foreground but not when the app is backgrounded. I have tried using BackgroundFetch and TaskManager, but they are not working. I found a workaround which uses WebView to run the function. I’ve tried WebView with console.log and it works in the foreground and background, but the sensor listener Accelerometer.addListener() does not get called anymore when the app is backgrounded.
I would appreciate any help regarding this.