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.

Messages/Notifications only populate when app is in the foreground

See original GitHub issue

Steps to reproduce

  1. Open the app.
  2. Navigate away from the app and/or close it in recent apps.
  3. Receive messages at some point while it’s in the background.

Outcome

What did you expect?

Notifications and messages should load up while the app is in the background.

What happened instead?

When opening up the app after having it in the background for a while and viewing a DM/chat, a loading bar will appear at the top and the chat will update and notifications will be sent at the same time.

Notably, I will always receive instant notifications and not see loading bars in chats while I keep the app open in the foreground, but as soon as it’s in the background the app essentially shuts off until I bring it back to the front and then it loads and catches back up again.

Notes:

  • This bugged behavior began on a fresh install of element on a brand new phone, and notably did not occur on the old one. I have not changed any notification related settings from their defaults on this new installation, and I successfully validated this new device using cross-signing.

  • I ran the notification troubleshooter and the result included the following issues:

    • Firebase Token (!)
      Failed to retrieved FCM token:
      java.util.concurrent.ExecutionException:
      java.io.IOException: SERVICE_NOT_AVAILABLE
      
    • Token Registration (!) (probably a cascade from previous failure)
    • Text Push (!) (probably a cascade from previous failure)
    • Notification Display step does work
  • Possibly relevant? In Advanced -> Notification Targets there are “No registered push gateways”

  • Data/Battery saver features in Android are at their defaults (off)

Your phone model

Pixel 6

Operating system version

Android 12

Application version and app store

1.3.7 [40103072] (G-b4267) Installed fresh off the Play Store, olm 3.2.4

Homeserver

matrix.org

Will you send logs?

No

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Autre31415commented, Dec 1, 2021

I was able to get notifications working!

I performed a whole flurry of steps and I’m not exactly sure which one did it, but I’ll list them all here in case others run into something like this:

  • I wiped all networks by going into System -> Reset Options -> Reset Wi-Fi, mobile, & Bluetooth.
  • I rebooted the phone in and out of safe mode (this seems to have reset some settings in various apps).
  • I disconnected from Wi-Fi for an extended period of time and ran the troubleshooter while on a mobile data network and it succeeded.

After that I checked and saw the push gateway in the list and from then on notifications worked both in and out of Wi-Fi.

1reaction
Autre31415commented, Nov 30, 2021

I just thumbed through the app manager and Google Play Services is indeed installed and the version number is the same as yours. In an attempt to debug at the services level I cleared the cache on it and restarted the phone, then started up element and ran the troubleshooter again and the result hasn’t changed. Notably the google play services step in the troubleshooter has passed without issue every time I’ve run it, with the failures being only the token cascade I originally marked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Silent notifications works only wh… | Apple Developer Forums
Hi, we need to use silent notifications in our app. Seems it works only when the app is in foreground or in debugging....
Read more >
Android notifications only received if app is in foreground
FirebaseMessagingService's "onMessageReceived()" method doesn't get called when your App is in background or closed. It happens ...
Read more >
Firebase Notifications in Background & Foreground in Android
The problem you have now is that your onMessageReceived is ONLY called when the app is in foreground, if you app if is...
Read more >
Receive messages in an Android app - Firebase - Google
Receive messages in an Android app ... Firebase notifications behave differently depending on the foreground/background state of the receiving app. If you want ......
Read more >
Notifications - Expo Documentation
Handle notifications when the app is in foreground,; Imperatively dismiss notifications from Notification Center/tray,; Create, update, delete Android ...
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