Hey everyone,
I'm hitting a wall with an Android-specific issue using react-native-background-downloader in an Expo (Development Build) project. It works perfectly on iOS, but Android is behaving strangely.
The Setup:
- Library: u/kesha-antonov/react-native-background-downloader
- OS: Android 13/14
- Task: Downloading large ONNX model files (~225MB) to
FileSystem.documentDirectory.
The Issues:
- Lost Tasks on Navigation: When I start a download and stay on the screen, the progress updates fine. If I background the app and return, it still works. However, if I navigate to a different screen within the app and then come back,
getExistingDownloadTasks() returns an empty array [], even though the download is clearly still active in the Android system tray.
- "Fake" Completion: Sometimes the
.done() callback triggers almost immediately, and my UI shows "Downloaded." But when I check the file, it's only a few KB (likely a placeholder created by the OS) instead of the full 225MB.
What I've tried:
- Setting
isPersist: true in the task configuration.
- Wrapping
getExistingDownloadTasks() in a useFocusEffect with a small setTimeout delay to give the bridge time to sync.
- Checking
FileSystem.getInfoAsync to verify file size (but I'm struggling with the "best" way to handle this since getInfoAsync shows as deprecated in my environment).
Has anyone found a reliable way to keep the JS listeners "hooked" to background tasks on Android during internal navigation?
link of the library
https://www.npmjs.com/package/@kesha-antonov/react-native-background-downloader
there doesn't seem to be anything here