flutter_foreground_service_plugin icon indicating copy to clipboard operation
flutter_foreground_service_plugin copied to clipboard

does not work when app killed by the user

Open xnio94 opened this issue 4 years ago • 6 comments

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 :

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)"

xnio94 avatar Aug 14 '20 05:08 xnio94

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) 

PriyaSindkar avatar Aug 15 '20 08:08 PriyaSindkar

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

FabulousGee avatar Aug 18 '20 20:08 FabulousGee

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

SGuzel avatar Aug 24 '20 10:08 SGuzel

did anyone find a solution for this?

xnio94 avatar Sep 24 '20 02:09 xnio94

Any idea?? still not working when app is closed, this means that the plugins is useless...

seo345 avatar Oct 07 '20 10:10 seo345

Is it working?if not how to resolve this?

Unzilla avatar Jan 17 '21 10:01 Unzilla