Comments (8)
it looks like I was able to do this with another notification package. Thanks for everything though.
from background_downloader.
Hi, happy to help. First, I don't think you'll be able to accomplish this with another package, as when you app moves to the background you won't be getting updates, and you won't be able to change your notification counter. So, unless you are no concerned about true background downloads, you will need to use the built-in groupnotification.
To take the 60 task example, let's call that a group of task and you give that group a unique id, yourGroupId
. You configure a notification for that group using
FileDownloader.configureNotificationForGroup(yourGroupId
running: const TaskNotification(
'{numFinished} out of {numTotal}', 'Progress = {progress}'),
complete:
const TaskNotification('Done!', 'Loaded {numTotal} files'),
error: const TaskNotification(
'Error', '{numFailed}/{numTotal} failed'),
progressBar: true,
groupNotificationId: yourGroupId);
This ensure that every task that is part of group 'groupId' will use this notification.
You then enqueue every one of you 60 tasks, but make sure that each task's group
is set to yourGroupId
.
That should get you the behavior that I think you want.
from background_downloader.
I tried what you suggested and in my example it shows 60 notification badge. If this number is even more, there will be high values like 1000.
Is there an option not to show the number of notification badge?
from background_downloader.
Depends on the platform. On Android, it should update the notification so there is only one. On iOS unfortunately that option does not exist, so it will generate a new notification if the text of the notification changes (so if you have a counter, it will indeed generate a new notification for every update). My suggestion would be to show only a "download in progress" type message on iOS, so that it doesn't repeat.
You said you had managed to do this with a different package, and I'm curious how they solved that issue on iOS. Can you share what package you used and the code you used to update (without triggering new notifications for every update)?
from background_downloader.
Specific to badge count, I think that's an app setting (to show that) on both platforms. When you describe behavior can you be specific as to what platform? Thanks!
from background_downloader.
I'm trying to improve myself on android devices with flutter. The package I mentioned above is "awesome_notifications: ^0.9.3+1".
As far as they mentioned, I can only implement the solution I mentioned on the android side. I haven't tried whether the application works for a long time in the background or not.
Also I wrote 60 notifications, I should have written Badge :,)
The code I wrote is realized with some controls and increasing the counters in the relevant places. However, while trying it on my physical phone, I realized that the number of badges is around 200 :,)
Maybe the "awesome" package has a feature to not show badges. I didn't look much.
some of the places I manage in my code
Future<void> startBulkDownload() async {
if (isDownloading.value == false) {
currentStep.value = 0;
maxTask.value = 0;
}
final int tempMaxTask = maxTask.value;
isDownloading.value = true;
await maxTaskCount();
if (maxTask.value == tempMaxTask) return;
// Initialize notification
await NotificationService.showNotification(
channelKey: 'progress_bar',
title: '...',
body: '0%',
notificationLayout: NotificationLayout.ProgressBar,
progress: 1.0,
locked: true,
);
taskStatusCallback: (update) async {
if (update.status == TaskStatus.complete && maxTask.value != 0) {
currentStep.value++;
if (kDebugMode) {
print("currentStep: ${currentStep.value}");
print("maxTask: ${maxTask.value}");
}
await NotificationService.showNotification(
channelKey: 'progress_bar',
title: '',
notificationLayout: NotificationLayout.ProgressBar,
progress: (currentStep.value / maxTask.value * 100).floor().toDouble(),
locked: true,
);
if (currentStep.value == maxTask.value) {
isDownloading.value = false;
currentStep.value = 0;
maxTask.value = 0;
await Future.delayed(const Duration(milliseconds: 700));
// Show completion notification
await NotificationService.showNotification(
channelKey: 'progress_bar',
title: '',
body: '',
notificationLayout: NotificationLayout.Default,
);
}
}
},
from background_downloader.
I don't think the downloader package explicitly asks for a badge indicator so not sure where that is coming from.
The code you show using the awesome package won't work as soon as your app moves to the background. It will then stop receiving updates and the counter will stop and not reflect the actual download count. That's why you have to use group notifications from the background downloader package.
from background_downloader.
Thank you very much for your replies.
from background_downloader.
Related Issues (20)
- Error information for failed downloads HOT 2
- Pleas help me ,Compilation failed, unable to get kotlin-serialization-compiler-plugin-embeddable-1.7.10.pom
- Execution failed for task ':background_downloader:compileDebugKotlin' HOT 1
- How i can resolve this issue? HOT 2
- Downloader works on Android but not on IOs (simulator) and TestFlight HOT 8
- Method to get TaskUpdate of a Task HOT 4
- [Android] Gradle MergeFailureException with compileSdkVersion 34 and Foreground Service HOT 3
- Start download from the beginning HOT 1
- Download notification do not show the progress HOT 1
- [Android] notification icon HOT 3
- Large attachment uploading takes a while HOT 2
- Build failure with `background_downloader` due to missing Kotlin plugin HOT 3
- Monthly issue metrics report for opened issues and prs
- Monthly issue metrics report for closed issues and prs
- Receive status update in background HOT 6
- Lack of Docs for `downloadBatch` HOT 1
- Upload tasks get randomly restarted on a slow Android device HOT 4
- Duplicate Task when uploading an image HOT 6
- Could not find org.jetbrains.kotlin:kotlin-serialization-compiler-plugin-embeddable:1.7.10. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from background_downloader.