Some ngCordova plugins not working!


#1

Hello There! I am facing some problems with some ngCordova (ionic Native) plugins.

I am trying to download an image from an URL to camera roll…

I am working inside Creator, I added ionic Native and i could run some of plugins like Vibration, Barcode scanner. They are working in my mobile. But I couldn’t run File Transfer. I tried everything, believe my every single code on internet but there is a problem and I am now sure it is not about me. A code or something has been changed.

When I debug my app in logcat i got this error;

[INFO:CONSOLE(26799)] "Error: [$injector:unpr] Unknown provider: $cordovaFileTransferProvider <- $cordovaFileTransfer <- pageCtrl

It looks like cordovaFileTransfer is not working anymore after ionic Native… I just noticed that in ionic native page its name is not cordovaFileTransfer anymore, it only uses Transfer… I am not sure, if there is a missing data on ionic documents… I couldn’t find any data about it?

Is there anybody could run file transfer in Creator??

Thanks


#2

Checkout line 187 onwards here: ionic-native/src/plugins/filetransfer.ts - this is the ionic native code for file transfer plugin.

I think to use File Transfer Plugin using Ionic Native in ionic V1 or Creator, you need to call $cordovaTransfer which will map to the necessary ‘cordova-plugin-file-transfer’ function calls.


#3

Thank you very much daniel! As you said, now i can call cordovaTransfer parameter.

I use that syntax as described in ionic native;

But there is a problem, it says downloaded completed in console… But i can not see in camera roll… Is there any way to save it to camera roll?

Thanks

download() {
const fileTransfer = new $cordovaTransfer();
let url = ‘http://www.example.com/file.pdf’;
fileTransfer.download(url, cordova.file.dataDirectory + ‘file.pdf’).then((entry) => {
console.log('download complete: ’ + entry.toURL());
}, (error) => {
// handle error
});
}
Note: You will not see your documents using a file explorer on your device.Use adb:

adb shell
run-as com.your.app
cd files
ls


#4

honestly, i’ve never used this file transfer plugin before so can’t help
much. But it does look like this plugin is simply for uploading and
downloading files. It doesn’t seem to do much with file management.

You might want to also look into “cordova-plugin-file” to work together
with the file-transfer plugin. This plugin seems dedicated to managing
device files and directories. It is also available on ionic-native.

But i’ve kind of given up on ionic native in creator. it works find for
some plugins but for others, ionic native doesn’t seem to be fully
implemented for ionic version 1 (which creator is based on). So now i just
call some of my plugins in creator directly without the ionic native
wrapper.


#5

Yes, as you said this plugin is just downloading the file to phone. I have to copy it from that uri to camera roll… Working on it for 10 hours, i think i am gonna find a way :slight_smile:
Thank you very much for your answers, you saved my tens of hours :slight_smile:


#6

THANK you, finally I found the same issue online. hope we can get this working. need it to upload data to mysql server. please let me know if you’ve found a solution ?