question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FCM notifications don't work if the app is terminated

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
rkfgcommented, Aug 16, 2020

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.

0reactions
atomtmcommented, Mar 18, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FCM notification not received when app is terminated
FCM notification not received when app is terminated. I'd like to ask a question regarding Firebase Cloud Messaging.
Read more >
FCM Notification not firing when app is killed - Stack Overflow
If you are running in debug mode then try totally terminate the application and launch without through IDE, launch from mobile/simulator.
Read more >
Notifications | FlutterFire
FCM via APNs does not work on iOS Simulators. ... on all platforms is to display a notification only when the app is...
Read more >
awesome_notifications | Flutter Package - Pub.dev
Notifications could be created at any moment (on Foreground, Background or even when the application is terminated/killed). High trustworthy on receive ...
Read more >
Receive messages in a Flutter app - Firebase - Google
On iOS, if the user swipes away the application from the app switcher, it must be manually reopened for background messages to start...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found