FCM notifications don't work if the app is terminated
See original GitHub issueDescribe the bug If the app is unloaded from memory for whatever reason (by the OS or force stop) there are no push notifications arriving anymore.
To Reproduce Steps to reproduce the behavior:
- Force stop the app
- Send yourself a message so that a push would be triggered
- There’s no push notification until you run the app manually
Expected behavior Pushes should arrive regardless the app state. FCM should deliver them to the system tray where the user can tap them to launch or open the running app.
Smartphone (please complete the following information):
- Device: Moto Power G7
- OS: Android 10
Additional context
- App version and store 1.0.4 [40100042] (G-b3378)
- Homeserver: my own
This might look like correct behavior at the first glance, if the user unloads the app they explicitly don’t want to receive notifications. But the OS can do the same if it needs memory and there’s no way to prevent that. The user would then miss messages which is a very bad UX. If the user wants to stop notifications there’s an option in the preferences for that.
Another case of notification delays is implicit Doze mode when the device is idle for 30+ minutes. Interestingly enough it’s not the same as triggering the Doze manually with adb shell dumpsys deviceidle force-idle
(in this case notifications get through). If my phone just lies motionlessly for an hour notifications will also stop until I wake it up and open the app. This shouldn’t be the case as the notifications have “high priority” flag by default and yet here we are. I know there are all sorts of nasty vendor tricks that improve UX in other messengers like WhatsApp or Viber. The phone vendors have whitelists for such apps that prevent them from unloading and losing incoming notifications. Element is not on these lists of course.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:8 (4 by maintainers)
No, it still doesn’t work after I disable battery optimization. This issue is specifically NOT about the F-Droid version which is expected not to work if you explicitly stop it (or the OS stops the background service for whatever reason). FCM is supposed to work all the time, it’s a system service which is able to show notifications on its own, without starting the app. From what I see and know, Element doesn’t use this functionality instead relying on showing the popups in
onMessageReceive
. Which is not called if the app is not running. I believe it would be much better to show the notification from FCM itself, without the content and such (for privacy reasons) but at least it would appear at all. After tapping it the app launches and user can read the details.Same issue here with notificatrions. On Xiaomi Note 9 Pro I am receiving notifications on Element Android GPlay when the application is active. If I switch to another app, I am not always receiving notifications / calls. Sometimes I do , sometimes not. Also all tests on notifications troubleshooter pass. Fluffychat seems to work reliable on notifications as others have stated.