Skip to content

Cap-go/capacitor-downloader

Repository files navigation

@capgo/capacitor-downloader

Capgo - Instant updates for capacitor

Download file in background or foreground

WIP: the plugin is not yet ready for production

Install

npm install @capgo/capacitor-downloader
npx cap sync

API

download(...)

download(options: DownloadOptions) => any
Param Type
options DownloadOptions

Returns: any


pause(...)

pause(id: string) => any
Param Type
id string

Returns: any


resume(...)

resume(id: string) => any
Param Type
id string

Returns: any


stop(...)

stop(id: string) => any
Param Type
id string

Returns: any


checkStatus(...)

checkStatus(id: string) => any
Param Type
id string

Returns: any


getFileInfo(...)

getFileInfo(path: string) => any
Param Type
path string

Returns: any


addListener('downloadProgress', ...)

addListener(eventName: 'downloadProgress', listenerFunc: (progress: { id: string; progress: number; }) => void) => any
Param Type
eventName 'downloadProgress'
listenerFunc (progress: { id: string; progress: number; }) => void

Returns: any


addListener('downloadCompleted', ...)

addListener(eventName: 'downloadCompleted', listenerFunc: (result: { id: string; }) => void) => any
Param Type
eventName 'downloadCompleted'
listenerFunc (result: { id: string; }) => void

Returns: any


addListener('downloadFailed', ...)

addListener(eventName: 'downloadFailed', listenerFunc: (error: { id: string; error: string; }) => void) => any
Param Type
eventName 'downloadFailed'
listenerFunc (error: { id: string; error: string; }) => void

Returns: any


removeAllListeners()

removeAllListeners() => any

Returns: any


Interfaces

DownloadOptions

Prop Type
id string
url string
destination string
headers { [key: string]: string; }
network 'cellular' | 'wifi-only'
priority 'high' | 'normal' | 'low'

DownloadTask

Prop Type
id string
progress number
state 'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR'

PluginListenerHandle

Prop Type
remove () => any

Credit

This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader