-
Notifications
You must be signed in to change notification settings - Fork 124
Foreground service stops on killing the application #3
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
Comments
I tried this flutter_foreground_service_plugin plugin and it luckily worked. It would be great if you can implement this behaviour in your plugin. Your plugin is built very nicely and thanks for building it, although this is the limitation for me that I can not ignore. |
Thank you. I checked the plugin. It seems to be possible to implement using |
Any updates? @Dev-hwang |
I'm busy working on other projects. Will update in the near future. |
@darshansatra1 The plugin has been updated. There are many changes, so please refer to the readme. |
Hi there! How did you fix this? For me, service still closes when I swipe the app out from "recents" 😕 I have pure stock android... I tried adding |
@TheLastGimbus |
Jeez this was so obvious, thanks!! Um by the way, it looks like hot-reload/even restart doesn't work for it at all D: I need to re-install the whole app for it to work :( Is this normal? Honestly it's okay if it's required - in exchange for working plugin 💖 there are so many of them and none work 😖 Edit: Okay, it's because the code is running in different Isolate, and this seems to be long-known flutter issue - can I somehow kill that Isolate to create a new one every time i stop and start the service? Oh and if may I ask one more question - I wanted to have my code work in more like "lifecycle" way - set things up before void globalMethod() async {
StreamSubscription stream =
Stream.periodic((const Duration(seconds: 1))).listen((event) async {
print("Stream :DD");
await FlutterForegroundTask.update(
notificationTitle: "Doing something...",
notificationText: event.toString(),
);
});
FlutterForegroundTask.initDispatcher(
(timestamp) async {
// Nothing in here
},
onDestroy: (timestamp) async {
await stream.cancel();
print('onDestroy D:');
},
);
} Everything should work, right? It does now when I try it, tho I wanted to ask because maybe you have some bad experiences or smth :P |
@TheLastGimbus void callback() {
final positionStream = Geolocator.getPositionStream();
StreamSubscription<Position>? streamSubscription;
FlutterForegroundTask.initDispatcher((timestamp) async {
if (streamSubscription != null) return;
streamSubscription = positionStream.listen((event) {
print('timestamp: ${timestamp.toString()}');
FlutterForegroundTask.update(
notificationTitle: 'Current GPS localization',
notificationText: '${event.latitude}, ${event.longitude}');
});
}, onDestroy: (timestamp) async {
await streamSubscription?.cancel();
print('callback() is dead.. x_x');
});
} |
Thanks! I'll do it like this About hot-reload: I tried Nevertheless - thanks very much for this plugin! Something finally works! |
No description provided.
The text was updated successfully, but these errors were encountered: