Search code examples
iosangularionic2file-transferionic-native

Ionic 2 fileTransfer.download not reacting on iOS


I've developed an Ionic 2 App on Android and am now trying to bring it to work on iOS.

The App downloads alot of files on initial login and I do that with the Ionic-Native Transfer plugin. On Android everything works fine, but on iOS the App seems to stuck in the promise of the fileTransfer.download() function, it doesnt even throw an error.

Example Code:

private downloadFile(downloadURL: string, filename: string) {
    return new Promise((resolve, reject) => {
        this.fileTransfer.download(downloadURL, this.file.dataDirectory + filename, true).then(_ => {
            console.log("download of " + filename + " complete");
            resolve("download finished");
        }).catch(err => {
            console.log(err);
            reject("download error");
        });
    });
}

I also tried to use the this.file.documentsDirectory instead for iOS but I still dont get any error or success outputs.

The downloadURL's are from an firebaseStorage link but I also tested it with a usual download URL.

I assume it does have something to do with permissions, but have not found a solution yet. The other assumption would be, that there is a limit to multiple threads on iOS there are about betwenn 30-100 promises live.

But the strange thing are the missing error messages, it just get stuck and not a single download finishes.

Any help is appreciated!

EDIT:

I still have not figured out the cause of the problem, but in the meantime, Ionic released a new version of the Transfer Plugin, which is now called FileTransfer in the official docs. Once I changed my code to use the new FileTransfer plugin, the problem disappeared.

I hope this helps others who faced the same problem.


Solution

  • I still have not figured out the cause of the problem, but in the meantime, Ionic released a new version of the Transfer Plugin, which is now called FileTransfer in the official docs. Once I changed my code to use the new FileTransfer plugin, the problem disappeared.

    I hope this helps others who faced the same problem.