flutter_foreground_service_plugin
flutter_foreground_service_plugin copied to clipboard
does not work when app killed by the user
I'm not sure if its the intended behavior or not but the callback does not fire if the user kills the app, the notification is always showing but it does nothing.
i tried with two tasks :
- change a document in firebase
- notify user using the flutter_local_notifications package
and in both cases, the plugin does not work when the app is killed (even if the foreground notification is still showing in the tray)
"extra: my use case is to run a callback periodically that check if the GPS is enabled, if yes update a document in firebase if not notify the user (this should work even if the user killed the app accidentally)"
I am facing the same issue when I switch off location permission from settings while the foreground service is still running
stacktrace-
java.lang.RuntimeException: Unable to start service changjoopark.com.flutter_foreground_plugin.FlutterForegroundService@2d593f7 with null: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3902) at android.app.ActivityThread.access$1700(ActivityThread.java:212) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1846) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6912) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference at changjoopark.com.flutter_foreground_plugin.FlutterForegroundService.onStartCommand(FlutterForegroundService.java:23) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3883) at android.app.ActivityThread.access$1700(ActivityThread.java:212) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1846) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6912) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
I have a similar issue. For me, my OS is stopping the main app after a few hours and then the callback isn't called anymore.
From what I understand, the method channel gets destroyed in the process (and flutter gets detached from engine). I am not sure though since this is all pretty hard to debug for me.
Any ideas how to solve this so far? I was thinking of re-starting the activity via intent maybe. I want to avoid moving all the stuff into an own plugin (which should also keep running then just like the foreground service) since I want to keep it in Dart
For me the same. If the app has been closed by the user, the foreground service is detached. App is killed and no more notifications.
Is there any fixes?
How to prevent the app being killed or how the delete the ongoing push notificaition too?
Thanks, -Sue
did anyone find a solution for this?
Any idea?? still not working when app is closed, this means that the plugins is useless...
Is it working?if not how to resolve this?