-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Remove AndroidServiceStartType
and update docs
#2481
base: master
Are you sure you want to change the base?
[Android] Remove AndroidServiceStartType
and update docs
#2481
Conversation
Seems the CI is failing because the example app is still using the old plugin syntax. I can open a PR for that sometime soon |
Looks good to me 👍 |
fixed in here |
Wait, I think we shouldn't remove the If a value has to be hard-coded, it should be the |
Not done testing on this but inclined to agree with @leaf-node and removing it seems more risky. I would suggest making this a required parameter. This way developers spend some time looking into the option that fits their scenario and the results are the consequence of the choice they made. |
@MaikuB, Levi offered more technical detail about this issue here: #2479, and I agree with a lot of what Levi says. My understanding is that the current feature is not working as intended, as the service is not resumed after it is paused by the OS. Ideally this could be resolvable for this package, perhaps by setting a callback that is called by the package when the foreground service is resumed by the OS. I'm currently working on creating a manual foreground service with my app's Kotlin code, which may give me some insight into how a foreground service works. I don't yet know enough to resolve / patch the issue on my own, but I might be able to help. Also, as Levi points out, there are other modules that try to provide foreground services on Android, with some different design decisions that don't fit my use case exactly. Many of them integrate with this package, and depending on how things go, I might create another alternative if the foreground service feature is removed from this package. |
@leaf-node thanks for the response. Based on my understanding, my preference would be to avoid removing the functionality as there could be cases where there are existing apps that choose to use this plugin to show the notification and start the operation independently. The one that seems to be problematic is the one tied to By the way, I don't think I've seen it mentioned but what is your actual use case? I saw you mentioned that picking |
@MaikuB The use case for my app is to fetch server alert statuses from third-party remote servers, and to notify the user if a new alert is found. I'm not using push notifications, so I create a foreground service, allowing my app to fetch from the network and create alert notifications. As for START_STICKY vs START_NOT_STICKY, if I could, I would prerfer former for my app, because (if I understand correctly) it will restart the app at the As for background isolates, I'm pretty sure that they are implemented as separate threads on the same It's possible to create a FlutterEngine that calls into a specific entrypoint in the Dart code, skipping the And the sticky options are to tell the OS whether an app's foreground service should be restarted after it is killed by the OS for memory cleanup, etc. I suppose in some cases, it might be useful to have a foreground service that runs for a while, then somewhat arbitrarily stops, but in my case I would want something that always, or usually, comes back, even if it takes a long time. I should also note that there is a 6 hour limit for foreground services in a 24 hour period, until the user interacts with the UI of the app again, unless the app uses a special permission that is harder to get into the Play Store. Some packages for background work operate by scheduling a series of timers. Between each tick, the app is not running, which might help with the time limit for the app. I'm still new to this topic, so it's not all 100% clear to me, but I'm learning. @Levi-Lesches does that match what you understand about this topic? |
What triggers this to run? Putting aside that there's an issue with
What you've described here is actually referring to background isolates and is what this plugin already leverages for handling notification actions that is required to trigger a callback on a background isolate. The reference in the official docs can be found here , which in turn refers to this. Have you tried flutter_foreground_task or did you find something that it's missing? Conscious that you may end up wasting time implementing a lot of what it already does that if it was missing something that you're better off forking it as a basis to add in what is missing |
So we all agree that Now, about If that's correct, then we should remove this option because it sounds like something useful is happening, and a notification means the user thinks something useful is happening, but nothing is happening at all. Again, haven't tested, but the code in |
@MaikuB I'm running a timer in Dart that then calls code to perform an HTTP request each time data is fetched by the app. I don't have an iOS version, largely due to a lack of a foreground service feature there. As for
@Levi-Lesches Are you thinking that it would currently make sense to require the |
Yes, since anything else would be misleading, but
I'm not sure this is ever going to happen, as we've mentioned that other packages like So I think the option should just be removed permanently, and |
@leaf-node thanks for the explanation. Have I missed something that's perhaps only in the implementation details or API docs? I've not taken a look at either in depth but the only mention of 15 minutes I've seen in the readme is specific to iOS and you don't have an iOS version for it be applicable |
@MaikuB Yeah, it looks like |
See #2479 for details on why this was needed (the option wasn't doing anything to begin with)
Fixes #2479
Fixes #2446
Fixes #2298
Fixes #2407