Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
796 stars 115 forks source link

Background Task Stops Prematurely on Android 12+ and Android 14 with react-native-background-actions #231

Closed meetanshisatpute closed 2 months ago

meetanshisatpute commented 2 months ago

Issue Description: I'm encountering a problem with the react-native-background-actions library on Android 12 and above. Despite configuring foreground service types and granting all required permissions as per the documentation, the background task only runs for 2-4 minutes before stopping abruptly when the app is killed.

Steps Taken:

Implemented foreground service types as specified. Ensured all necessary permissions (ACCESS_FINE_LOCATION, ACCESS_BACKGROUND_LOCATION, etc.) are granted. Verified that the app is correctly configured to handle background tasks.

Expected Behavior: The background task should continue to run reliably in the background on Android 12 and above, without being terminated prematurely.

Additional Information: Library Version:4.0.0 Android Device OS: Android 12+Android 14 Development Environment: React Native 0.74.3

Any guidance or insights into resolving this issue would be greatly appreciated. Thank you!

Rapsssito commented 2 months ago

This is common, as the OS has absolute control over the background processes of the device. See https://github.com/Rapsssito/react-native-background-actions/issues/22#issuecomment-628737527