element-hq / element-hq/element-android
FCM notifications don't work if the app is terminated
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
**Describe 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:
1. Force stop the app
2. Send yourself a message so that a push would be triggered
3. 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.
Contributor guide
Assessment
This issue has not been assessed yet.