Closed rydal closed 5 years ago
From my understanding, isolates like that do not work when the app isn't running. Invoking code whilst the app is terminated relies on native APIs. What I've seen others do is rely on the background_fetch plugin. It only supports headless execution (i.e. the ability to execute Dart code without the app running) on Android though. It's not something I've used but if this is sufficient for what you need to do then I would suggest you ask on, say, Stack Overflow given this is more of an issues list so the chances of the community see your request help is more slim.
Thanks for your reply. Just to confirm we are on the same page the notifications can't be run as an isolate? If you want i can provide more code. The example was a test case scenario.
My hope was that after the app was killed the isolate would persist to show notifications.
Thanks.
Rob.
Correct but I should clarify since it appears you may have not understood what I wrote. Flutter won't be able to run your code in an isolate when the app has been terminated at all without setup on the side of the native platform. This is why I suggested looking at the background_fetch plugin. A member of the Flutter team had written an article on what's involved as well but may be a bit out of date https://medium.com/flutter/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124
Hi Maiku,
Thanks for such a useful plugin. I accept i might have something wrong here, i find the notificaitons run ok when the application is there but not as an isolate. When the user kills the app the notifications cease to be displayed by the isolate.
I expect the notifications to be shown but, whilst the FlutterIsolate continues to run the notifications are not being shown. I belive this might be related to the context but i'm not sure.
Code is below:
I tried moving the spawn thread to the main class. If you or anyone can advise on how to make the applications persist that would be great.
Thanks, Rob.