We are developing an app which uses Native File Transfer plugin. But due to a weird issue we can not create the Test Flight / Release Build for iOS.
Issue:
Even after successful installation of the ‘File Transfer’ plugin we see the following error while running the app with
ionic cordova run ios -lc
console.warn: Native: tried accessing the FileTransfer plugin but it's not installed.
Current behavior:
As we tap a button that invokes the fileTransfer.download(…) method - the app halts to perform without throwing any Error.
Console Output
[19:21:39] console.log: Hello MediaIos Provider
[19:21:39] console.log: Ionic Native: deviceready event fired after 2822 ms
[19:21:39] console.log: fileTransfer:
[19:21:39] console.log:
{"FileTransferErrorCode":{"FILE_NOT_FOUND_ERR":1,"INVALID_URL_ERR":2,"CONNECTION_ERR":3,"ABORT_ERR":4,"NOT_MODIFIED_ERR":5}}
[19:21:39] console.log: platform ready now
[19:21:39] console.log: AuthToken Checking Complete
[19:21:39] console.log: ViewDidLoad SelectSurvey
[19:21:39] console.log: ionViewDidEnter SelectSurvey
[19:21:51] console.log: fileTransfer:
[19:21:51] console.log: provider ios: {}
[19:21:51] console.log: documentsDirectory:
file:///var/mobile/Containers/Data/Application/E92C5A5F-4ABB-4ECF-8AED-C45B19468155/Documents/
[19:21:51] console.log: download started on uri: http://xxxxxxxx.com/softwareapp/media/xxxxxxxx.zip
I would like to draw attention at the following lines -
1:
[19:21:39] console.log:
{"FileTransferErrorCode":{"FILE_NOT_FOUND_ERR":1,"INVALID_URL_ERR":2,"CONNECTION_ERR":3,"ABORT_ERR":4,"NOT_MODIFIED_ERR":5}}
The above is the result of the console.log() we placed inside the platform.ready() function as follows:
console.log('fileTransfer: ');
console.log(JSON.stringify(this.fileTransfer));
The console.log(JSON.stringify(this.fileTransfer)); at least prints an object with some properties.
2: Now, we placed the same two lines of console.log() in the provider where the download operation code resides. The output printed on the console is surprisingly different as follows:
[19:21:51] console.log: fileTransfer:
[19:21:51] console.log: provider ios: {}
The second line of console.log() just prints an object literal ( EMPTY OBJECT !!! ??? )
And at this point - the app stops without throwing further Error and the download never completes.
As a side note, I would mention that the Android Version of the finished app already been released on Google Play and working fine with all its features.
Plugin List
As we run ionic cordova plugin list we get the following output on the console window:
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-screen-orientation 2.0.1 "Screen Orientation"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
com.hutchind.cordova.plugins.streamingmedia 0.1.4 "StreamingMedia"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
cordova-sqlite-storage 2.1.1 "Cordova sqlite storage plugin"
cordova.plugins.diagnostic 3.7.1 "Diagnostic"
ionic-plugin-keyboard 2.2.1 "Keyboard"
Related code:
The actual download function is as follows:
download_media_files() {
//
console.log('fileTransfer: ');
console.log('provider ios: ' + JSON.stringify(this.fileTransfer));
//
this.fileTransfer.onProgress((e) => {
this.process_str = 'Downloading ... '
this.process_progress = (e.lengthComputable) ? Math.round(e.loaded / e.total * 100) : -1;
console.log("progress: " + this.process_progress);
})
let uri = encodeURI(this.zip_path);
//
console.log('documentsDirectory: ' + this.file.documentsDirectory);
console.log('download started on uri: ' + uri);
this.fileTransfer.download(uri, this.file.documentsDirectory + '/media/xxxx.zip').then((entry) => {
console.log('download complete: ' + entry.toURL());
// to unzip the downloaded zip file
this.unzip_files();
}, (error) => {
console.log('error block');
console.log(error);
})
}
Other information:
Ionic info
: output is as follows:
ionic info
cli packages: (/Users/<user-name>/.nvm/versions/node/v8.3.0/lib/node_modules)
@ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.1
Cordova Platforms : ios 4.5.3
Ionic Framework : ionic-angular 3.8.0
System:
ios-deploy : 1.9.2
Node : v8.3.0
npm : 5.5.1
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Can anyone help ??