Download a file in the background with FileTransfer in an ionic, phone call

I have packaged my AngularJS / javascript app using phonegap / Cordova for Android and I am planning to do it for iOS / BlackBerry later. In this project, I have implemented the FileTransfer.download function from the phonegap API to download a file from the server. The function works successfully, but it blocks me from navigating to other pages in the application until the download is complete.

Perhaps I am missing something in the documentation: What's the best way to get FileTransfer.download to run in the background so that I can move freely from page to page? Is this possible without resorting to a specific device?

+3


source to share


1 answer


Using the FileTransfer plugin is not really required to download files in a phone hesitation. You can do this directly in javascript and it shouldn't block your UI (even though JS is a mono thread, the thread shouldn't collapse on async load).

I suggest you use downgularJS - https://github.com/kaikcreator/downgularJS



This AngularJS module can be easily integrated with ionic, it uses the cordova API and does not require a file transfer plugin . You can create multiple queues for uploading files and perform any operation after uploading files, and this is pretty well documented.

+1


source







All Articles