react-native-background-downloader
react-native-background-downloader copied to clipboard
Differences between checkForExistingDownloads and ensureDownloadsAreRunning?
Hi! Im in doubt which method i must use. In documentation, the "check" method is used as a preparation of "ensure" method, but in the same times, the documentation has said that those two methods are used to resume a download. So, my question is: Can I use only the checkForExistingDownloads to resume a download, in view of "ensure" method can only been used in iOS devices. Tks a Lot!
Hi
As you can see here:
https://github.com/kesha-antonov/react-native-background-downloader/blob/1f52afe3d4359d9c66f0216c3e89b1ae7a7a5f6e/index.ts#L95-L105
ensureDownloadsAreRunning
is just wrapper around checkForExistingDownloads
to get tasks and call pause
& resume
on them to ensure they're running. It's good to call this method when app resumed from background - in case when you have problem when downloads stuck sometimes.
So you don't need to call checkForExistingDownloads
as a preparation
checkForExistingDownloads
is good to use on app startup when you want to re-attach those tasks to your app logic