@bricks-soft/cap-downloader
v8.0.2
Published
Download files using Android Download Manager and iOS background URLSession
Readme
cap-downloader
Download files with Android Download Manager or an iOS background URLSession.
On iOS, download() resolves after the transfer is queued. The native session
continues while the app is suspended, stores completed files in
Documents/Downloads with iCloud backup disabled, and posts a notification that
opens the downloaded file. Immediate queue failures reject the promise; later
transfer failures are reported with a native notification. A user force-quit
cancels active iOS background transfers.
The first iOS download requests notification permission. Queueing fails if the permission is denied because notifications provide the completion and open-file interaction.
Install
npm install @bricks-soft/cap-downloader
npx cap syncFor iOS background relaunch handling, forward the application delegate callback:
import BricksSoftCapDownloader
func application(
_ application: UIApplication,
handleEventsForBackgroundURLSession identifier: String,
completionHandler: @escaping () -> Void
) {
if !CapDownloaderPlugin.handleEventsForBackgroundURLSession(
identifier,
completionHandler: completionHandler
) {
completionHandler()
}
}API
download(...)
download(options: Options) => Promise<{ id?: number; }>| Param | Type |
| ------------- | ------------------------------------------- |
| options | Options |
Returns: Promise<{ id?: number; }>
Interfaces
Options
| Prop | Type |
| -------------- | ------------------- |
| title | string |
| url | string |
| filename | string |
| mimetype | string |
