Open tkem opened 7 years ago
Hello, Thank you for this precise description. I experienced the same issue, but I was not able to find a proper solution :( There is a "notification killer service" in the plugin that should kill the notification when the app dies. It seems that the service detects when the user manually kills the app, but not when the system does it after some time ...
I'm by no way an expert in Android system programming, but if I understand correctly, Android may literally "kill" an app running in the background at any time without further notice. Since this doesn't seem to trigger the "notification killer service", I can think of two possible solutions:
prevent an app in the background from being killed as long as the MusicControls notification is active; https://github.com/katzer/cordova-plugin-background-mode seems to do something like that, but I guess this would open a whole can of worms (store compliance included)
add a "ping" broadcast that's sent by the MusicControls notification every N seconds; this wouldn't be passed to Cordova event callbacks, but handled directly by MusicControlsBroadcastReceiver
, by updating the notification. If a "ping" message is not handled by the app for a given amount of time, the notification can assume the app is "dead" and exit (or whatever the killer service does).
As I said, I don't know much about Android native programming, so I don't know if my proposed solution/workaround is feasible in any way...
I noticed that the MusicControls notification keeps getting shown when my app is "killed" by Android after a period of inactivity. If the app is "paused", i.e. put in the background, and I terminate it manually (by swiping it from the recent apps list), the MusicControls notification is closed after a short delay (1-3 sec). If I keep it in the background, e.g. over night, the app will get killed silently at some time. Apparently, MusicControls does not notice this, and prev/play/next buttons will no longer work. Clicking the track image will restart the app, splash screen and all, though.