Hello, with the help of some members of this community, I was able to access the file system and create folder in iOS, but when I try to download a file from an API (server) to that folder, it does not work on iOS but works fine on Android. I am using PhoneGap Build
My current config file:
My download code, this below saves a file with format = "name.originalExt.pdf" so something like test.doc.pdf.
Any suggestions?
Thanks
Yuriy
My current config file:
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.app.reflex" version="0.0.1">
<icon src="img/icons/icon57.png" width="57" height="57" />
<icon src="img/icons/icon57.png" gap:platform="ios" width="57" height="57" />
<icon src="img/icons/icon72.png" gap:platform="ios" width="72" height="72" />
<icon src="img/icons/icon114.png" gap:platform="ios" width="114" height="114" />
<icon src="img/icons/icon120.png" gap:platform="ios" width="120" height="120" />
<icon src="img/icons/icon144.png" gap:platform="ios" width="144" height="144" />
<icon src="img/icons/icon152.png" gap:platform="ios" width="152" height="152" />
<name>Reflex</name>
<description>App.</description>
<author href="http://cordova.io" email="customerservice@mydomain.com">App</author>
<content src="index.html" />
<access origin="*"/>
<preference name="phonegap-version" value="3.7.0" />
<preference name="permissions" value="none" />
<preference name="orientation" value="portrait" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="auto" />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="8.0" />
<gap:plugin name="org.apache.cordova.camera" source="npm"/>
<gap:plugin name="org.apache.cordova.media-capture" source="npm"/>
<gap:plugin name="org.apache.cordova.contacts" source="npm"/>
<gap:plugin name="org.apache.cordova.device" source="npm"/>
<gap:plugin name="org.apache.cordova.file" source="npm" />
<gap:plugin name="org.apache.cordova.file-transfer" source="npm" />
<gap:plugin name="org.apache.cordova.media" source="npm"/>
<gap:plugin name="org.apache.cordova.splashscreen" source="npm"/>
<gap:plugin name="org.apache.cordova.vibration" source="npm"/>
<gap:plugin name="cordova-plugin-flashlight" source="npm" version="3.0.0"/>
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<gap:plugin name="org.apache.cordova.dialogs" source="npm"/>
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm"/>
<icon src="icon.png"/>
<plugin name="InAppBrowser" value="CDVInAppBrowser" />
</widget>
My download code, this below saves a file with format = "name.originalExt.pdf" so something like test.doc.pdf.
function startDownloadProcess(fileurl, fn) {
// alert("start process: fileurl: " + fileurl + " filename: " + fn);
wait();
fullFileURL = fileurl;
window.resolveLocalFileSystemURL(docPath.toURL() + fileName, fileExists, downloadAsset(fileurl, fn));
}
// download file
function downloadAsset(url, fn) {
var options = new FileUploadOptions();
options.mimeType = "application/json";
options.httpMethod = 'GET';
var headers={'auth': window.localStorage.getItem("auth")};
options.headers = headers;
var fileTransfer = new FileTransfer();
alert("About to start transfer ... " + docPath.toURL() + "Documents/" + fn);
fileTransfer.download(encodeURI(url + '//' + window.localStorage.getItem("auth")), docPath.toURL() + "Documents/" + fn + ".pdf",
function (entry) {
alert("Download complete.");
},
function (err) {
alert("Download error code: " + err.code);
}, options
);
}
Any suggestions?
Thanks
Yuriy



Yuriy Mirskiy
Also, the gap:plugin element needs to be removed? If yes, how would I add the plugins to PhoneGap Build?
What does not work is the actual FileTransfer()'s download function. But it only does not work for iOS, it works fine for Android. I am able to download the file into the specified folder. On iOS, this alert is the only thing that gets called:
alert("About to start transfer ... " + docPath.toURL() + "Documents/" + fn);
What is strange, the download function's callback for success or error are not called either. It gets stuck on download function and that's it.
Thanks for your response and help
Yuriy
Petra V., Champion
2. I didn't say "remove every gap:plugin element", but just the "plugin" element from your config.
3. Could it be that the download just hangs in iOS9? Have you tried previous iOS versions?
Yuriy Mirskiy
<plugin name="InAppBrowser" value="CDVInAppBrowser" />element.The original version that I tried on was 9.1. I tried to run it on an emulator using 8 but the app won't run at all.
Yuriy Mirskiy
Yuriy Mirskiy
Yi Ming Kuan
-yiming
Yuriy Mirskiy