Skip to content
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

Question/Request - Communication need between background isolate of action and main isolate #2517

Closed
mmmeeedddsss opened this issue Jan 16, 2025 · 2 comments

Comments

@mmmeeedddsss
Copy link

Describe the request
I have a use case for background notification actions, which triggers some changes in the data store of the application. The action itself should be a background action, since I don't want it to open the UI if the application is closed.

The issue is, if the application is running, and user picks these actions while the application is on the foreground, the UI of my application cannot get refreshed since the main isolate cannot know if the data store is changed or not.

As far as I could read, the recommended approach is to pass SendPort to the created isolate but the onDidReceiveBackgroundNotificationResponse method doesn't allow for such a change.

My question is, if it is possible to create a communication link between background isolate that is triggered by a notification action and the main isolate, if it exists.

If it is not something possible, please consder my message and use case as a feature request for users of the app to be able to create such communication channels.

To Reproduce

  1. Have an application storing state in a persistent store, and showing that information on UI
  2. Register a notification with a background action. This action triggers the state in the persistent store to change.
  3. While the app is open, trigger the action of your notification and observe that the state in the persistent store changes while the UI stays the same since the application hasn't been notified about the change in the persistent store(sinceaction and main isolates are seperate, there is no way visible to me to notify the main isolate as of now)

Expected behavior

  • If it is possible to create a communication channel between background isolate and main isolate, the documentation to explain how.
  • Making it possible to create of such a communication channel
@mmmeeedddsss
Copy link
Author

Hello,

I have been able to read a bit more on the isolates and was able to communicate between two of the isolates(the main isolate and the isolate spawned by the background action) using flutter's IsolateNameServer. I can either close this issue, or ask your idea about adding that detail to the documentation. If you wish, I can also add a small mention to IsolateNameServer to the documentation as a contribution.

Have a great day!

@Levi-Lesches
Copy link
Contributor

Hi, thanks for bringing this up! I'm in the process of re-shaping the plugin's documentation. This was on my list but hasn't been added yet. You can keep up with my (slow) progress at #2477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants