繁体   English   中英

flutter_downloader 在 iOS 中不显示下载通知

[英]flutter_downloader doesn't show notification of downloading in iOS

我在应用程序中使用flutter_downloader来允许下载 pdf 文件。 它在Android中运行良好,但在IOS中,虽然设备中下载了文件,但没有出现开始下载文件的通知。

我遵循了启用后台模式、添加 sqlite 库、配置 AppDelegate 中描述的所有说明

代码:

                                       final status = await Permission.storage.request();
                                        if (status.isGranted) {

                                          // Directory _path  = await getExternalStorageDirectory();
                                          //  String _localPath = _path.absolute.path + Platform.pathSeparator + 'ESPRS_Docs';

                                          var savedDir;
                                          if (Platform.isIOS) {
                                            savedDir = await getApplicationDocumentsDirectory();
                                          } else {
                                            savedDir = Directory('/storage/emulated/0/Download');
                                            // Put file in global download folder, if for an unknown reason it didn't exist, we fallback
                                            // ignore: avoid_slow_async_io
                                            if (!await savedDir.exists()) savedDir = await getExternalStorageDirectory();
                                          }

                                          String random_no =randomAlphaNumeric(6) ;
                                          var split_name=p_title.replaceAll(" ","-");

                                           await FlutterDownloader.enqueue(
                                            url: p_link,
                                            savedDir: savedDir.path,
                                            fileName: "${split_name}-${random_no}.pdf",
                                            showNotification: true,
                                            saveInPublicStorage: true,
                                            openFileFromNotification: true,
                                            headers: {"auth": "Downloader"},

                                          );


                                        }else {
                                          print("Permission deined");
                                        };

下载进度通知消息仅适用于 Android。 不同平台的行为不同。

final taskId = await FlutterDownloader.enqueue(
  url: 'your download link',
  savedDir: 'the path of directory where you want to save downloaded files',
  showNotification: true, // show download progress in status bar (for Android)
  openFileFromNotification: true, // click on notification to open downloaded file (for Android)
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM