-
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
Callback when scheduled notification is shown #21
Comments
Can you give me a sample use case for that feature? Also, from my understanding this is blocked on the Flutter engine as it needs to be able to fire callbacks even the app is terminated. It's the same reason why I haven't added the ability to define custom actions #17 |
Use case: event reminder showing how much time left to event. We need to constantly update such reminder. |
I can try to take a look but concerned on if the Flutter API will change to not use isolates if they figure out how to get it working for iOS. Don't know what you mean on how it's not possible for native iOS but at the least this is exposed on iOS |
Had more thoughts about this. Even if Flutter provides headless Dart-support for iOS, providing a callback/event that doesn't work the same way across all platforms doesn't align with my goal of providing cross-platform abstractions. So, unfortunately I won't be looking to add this and recommend you implement the functionality yourself. You could have your application reference a local copy of the plugin's code that also includes your own customisations to handle this scenario |
On second thought, I'm going to reopen this as an alternative is to handle the callback as part of the NotificationDetailsAndroid class as opposed to callback that is associated with the FlutterLocalNotificationsPlugin class. That is, once I figured out how to make use of the headless Dart code execution capability... |
Tried to take a look at this and had some success but every now and then I'll run into exceptions on the Flutter side. Not too sure if it's a stability issue with Flutter or not at the moment but if someone out there is able to help then it'd be much appreciated. Code is on the What I have found is that headless execution will only work on callbacks that fire top-level or static functions. Unless I'm missing something, I believe this means separate callbacks are required depending on if they require the app to be running as top-level/static functions won't get access to a BuildContext (e.g. to trigger navigation) and wasn't able to start the app using just code on the Dart side using top-level/static functions (e.g. by call |
Hi! Apologies if this doesn't change much but I noticed in flutter/flutter#21925 support for doing background work that accesses plugins in iOS is now supported. Any chance of being able to update the onnotification_callback branch with master so I can try it out with the latest code? Really eager to have some background execution work in flutter! Thanks. |
There's actually another issue I've raised since I had noticed the headless execution could stop working that from what I gather, will require a solution from Flutter on dealing with plugins that use multiple isolates. I believe that is still ongoing |
Here is my solution to this: Add the following method for iOS:
This should trigger didReceiveLocalNotificationSubject. See attached . |
@real1900 note that only works if the app is in the foreground. To follow up I'm going to close this issue as it's been around as it's been around for two years now and the background execution process for Flutter hasn't had changes and may even no longer be supported. Feel free to fork the repo and modify the code to support the cases you need |
@radzish I agree with you! Finally I did like this
|
ahhhhh. |
It would be really nice to have a callback that would be called when notification is shown.
The text was updated successfully, but these errors were encountered: