flutter_downloader在iOS中不显示下载通知

llycmphe  于 2023-04-07  发布在  Flutter
关注(0)|答案(1)|浏览(172)

我在应用程序中使用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");
                                        };
bxjv4tth

bxjv4tth1#

下载进度的通知消息仅在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)
);

相关问题