flutter_downloader
flutter_downloader copied to clipboard
Download is not working in IOS Simulator
We have implemented flutter_downloader library for downloading the either jpg/pdf files. Its working fine in Android Devices. But when we are trying to download in IOS Simulator we'r getting the error : URLSession:task:didCompleteWithError: in xCode.
For IOS , followed the complete guidelines which has mentioned in the library documentation.
IOS Version : 14.4
String savedDirPath = Platform.isAndroid ? await ExtStorage.getExternalStoragePublicDirectory( ExtStorage.DIRECTORY_DOWNLOADS) : (await getApplicationDocumentsDirectory()).path;
await FlutterDownloader.enqueue( url: baseURL + downloadUrl, savedDir: savedDirPath, showNotification: true, openFileFromNotification: true, );
Im facing the same issue.. Couldn't find any soultion.
facing same issue have asked about it here https://stackoverflow.com/questions/67336422/flutter-downloader-not-working-with-dynamic-url https://github.com/fluttercommunity/flutter_downloader/issues/463
Little update on this.. File is being downloaded but it is not displayed in device.. ive used then method after downloading file. Something like this> await FlutterDownloader.enqueue( url: "someUrlFromApi", savedDir: externalDir.path, // fileName: fileName, showNotification: true, openFileFromNotification: true, ).then( (value) => Snacks.darkSnack( title: 'Downloaded', subtitle: 'Click here to open', onTap: (_) { FlutterDownloader.open(taskId: value); }, ), );
And it opens that files but. doesn't give any preview of it
Little update on this.. File is being downloaded but it is not displayed in device.. ive used then method after downloading file. Something like this> await FlutterDownloader.enqueue( url: "someUrlFromApi", savedDir: externalDir.path, // fileName: fileName, showNotification: true, openFileFromNotification: true, ).then( (value) => Snacks.darkSnack( title: 'Downloaded', subtitle: 'Click here to open', onTap: (_) { FlutterDownloader.open(taskId: value); }, ), );
And it opens that files but. doesn't give any preview of it
do you use dynamic download links?
I dont know what exactly you mean by dynamic download links
i mean to say that i get my download url end point from another api and i append that end point in base url . when i pass static url it downloads file correctly and i can view and open it but as soon as i pass dynamic url it doesnt download.
Oh, Yes my download url is also coming from and endpoint.. How are you able to see file? Can you please share code snippets
i already shared code in the question i asked. i have attached the link in previous comments
Hey i think there must be some issue in your link. Your code where BASE_URL="http://server.com" // it should be like. http://server.com/endpoint/file.pdf DOWNLOAD_PDF="endpoint/" fileName="file.pdf"
await FlutterDownloader.enqueue(
url: BASE_URL+DOWNLOAD_PDF+fileName, // HERE I GUESS IT IS NOT GETTING PROPER URL
savedDir: value,
showNotification: false,
openFileFromNotification: false)
In my case, when i checked the Application folder of IOS Simulator through Finder the file is got downloaded. But in Notification its not displaying like how it displays in Android.I didn't checked with the real device.
In my case, when i checked the Application folder of IOS Simulator through Finder the file is got downloaded. But in Notification its not displaying like how it displays in Android.I didn't checked with the real device.
Yes no notifications for me as well, Checked on real device too. Also ive enabled background mode too as mentioned in docs
in iOS 15 I can't see downloaded file
Did anyone find the solution ? Everything works fine in android. But files are not downloading in ios and these functions ( showNotification: true, openFileFromNotification: true,) are also not working. Is there an alternative to show download progress or openFromNotifications function for ios ?
Hello,
Any update on this matter? Not working on IOS
hello, any update for this issue ? i not yet find the solution
Hello,
it worked from my side. As far as i can tell i added the following config :
saveInPublicStorage: true,
savedDir: ((await Helper().findLocalPath())! + "/folder_app" ),
showNotification: false,
where the findlocal function is:
Future<String?> findLocalPath() async {
var externalStorageDirPath;
if (Platform.isAndroid) {
try {
final directory = await getExternalStorageDirectory();
externalStorageDirPath = directory?.path;
} catch (e) {
final directory = await getExternalStorageDirectory();
externalStorageDirPath = directory?.path;
}
} else if (Platform.isIOS) {
externalStorageDirPath =
(await getApplicationDocumentsDirectory()).absolute.path;
}
String _localPath = externalStorageDirPath! + '/folder_app';
final savedDir = Directory(_localPath);
bool hasExisted = await savedDir.exists();
if (!hasExisted) {
savedDir.create();
}
return externalStorageDirPath;
}
Try to add these two keys in Info.plist. Source file_saver Thanks to that I am able to see saved files on real iPhone.
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
iOS 15.5 Virtual Machine iPhone 8 issues?
- Android work fine, but when I using function open file current version not working =((
- iPhone has downloaded file but file is not my expectations, my file is PDF but file download is another format (download_task.sql), So something wrong with my code?
- Below is my code with findLocalPath() function using @kareemzok
- FlutterDownloader.registerCallback(downloadCallback); await FlutterDownloader.enqueue( url: url, savedDir: await findLocalPath(), showNotification: true, openFileFromNotification: true, saveInPublicStorage: true, ).then((taskId) async { hideLoading(); if (taskId != null) { showMessages('Download is success!'); } });