Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Downloader

Improve this doc

This plugin is designed to support downloading files using Android DownloadManager.

Repo: https://github.com/Luka313/integrator-cordova-plugin-downloader.git

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add integrator-cordova-plugin-downloader
    $ npm install --save @ionic-native/downloader@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Downloader } from '@ionic-native/downloader/ngx';


constructor(private downloader: Downloader) { }

...

   var request: DownloadRequest = {
          uri: YOUR_URI,
          title: 'MyDownload',
          description: '',
          mimeType: '',
          visibleInDownloadsUi: true,
          notificationVisibility: NotificationVisibility.VisibleNotifyCompleted,
          destinationInExternalFilesDir: {
              dirType: 'Downloads',
              subPath: 'MyFile.apk'
          }
      };


  this.downloader.download(request)
              .then((location: string) => console.log('File downloaded at:'+location))
              .catch((error: any) => console.error(error));

Instance Members

download(request)

Starts a new download and returns location of the downloaded file on completion

Param Type Details
request DownloadRequest

NotificationVisibility

Param Type Details
Visible 0
VisibleNotifyCompleted 1
VisibilityHidden 2
VisibleNotifyOnlyCompletion 3

Header

DestinationDirectory

Param Type Details
dirType string
subPath string

DownloadHttpHeader

Param Type Details
header string
value string

API

Native

General