flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

Add option to download only via wifi

Open lyio opened this issue 3 years ago • 7 comments

  • Add allowCellular flag to the enqueue that defaults to true
  • Add separate NSURLSession on iOS that sets allowsCellularAccess false in its configuration
  • Schedule download requests with one of the two sessions depending on the flag of the download
  • Add the flag to the Android plugin and set the network constraints to either NetworkType.CONNECTED or NetworkType.UNMETERED depending on the value of the flag
  • Migrate sql database on Android to keep track of the flag

Closes #408

lyio avatar Jul 28 '21 11:07 lyio

@hnvn Is this something you would consider reviewing if the conflicts are resolved?

kuhnroyal avatar Oct 29 '21 12:10 kuhnroyal

Thanks @lyio and @kuhnroyal for this PR. Android implementation is good for me but it seems that iOS implementation is missing configuration for DB scheme. On iOS, we have a pre-defined DB scheme in file download_tasks.sql in ios/Assets/ folder

hnvn avatar Mar 17 '22 02:03 hnvn

@hnvn it works fine on iOS without updating the schema for some reason. I'll see to it that the file is updated, though.

lyio avatar Mar 18 '22 15:03 lyio

@hnvn I have a couple of questions regarding the scheme. I have updated the binary database file to include a new column allow_cellular.

I have not seen anything in the Objective-C code suggesting that any form of migration strategy is applied. On Android the database is cleared and recreated when changes are made, but on iOS I don't see anything like that.

Am I missing something here?

Do we need to add this first? Because otherwise my changes will have no effect on existing installations as the file is only copied over if it does not exist yet.

lyio avatar Mar 21 '22 08:03 lyio

The iOS implementation comes without migration solution. I currently don't find down any solution for it. That's why I am quit hesitate to add new field to DB schema. New field on DB need to release as a major update

hnvn avatar Mar 25 '22 10:03 hnvn

The Android solution to the problem seems to be, to simply delete the DB and create it again when the version changes.

lyio avatar Mar 25 '22 10:03 lyio

@hnvn do you have a migration path for iOS in mind?

lyio avatar Aug 10 '22 06:08 lyio

Due to all the changes in the meantime (especially the migration to Kotlin), I have a hard time rebasing this and still getting it to work.

I will close this PR and make a new one.

lyio avatar Nov 09 '22 08:11 lyio