Skip to content

[πŸ›] FCM onMessage stops working after app goes to background and comes backΒ #8736

@cemalturkcan

Description

@cemalturkcan

Problem

Using @react-native-firebase/messaging on Android. The onMessage listener works fine when the app first opens, but after I put the app in background and then bring it back to foreground, onMessage stops firing completely. Only way to fix it is to restart the app.

Background notifications still work fine, it's only the foreground listener that breaks.

Environment

  • Expo SDK 53
  • React Native 0.79.6
  • @react-native-firebase/messaging 23.4.1
  • Android 14+

Steps to reproduce

  1. Set up a foreground listener:
useEffect(() => {
  const unsubscribe = messaging().onMessage(async (message) => {
    console.log('Foreground message:', message);
  });
  return () => unsubscribe();
}, []);
  1. Send notification while app is in foreground β†’ works
  2. Put app in background, send notification β†’ works
  3. Bring app back to foreground, send notification β†’ doesn't work
  4. Kill app and reopen β†’ works again

What I've tried

  • Switched from modular imports to singleton API (messaging())
  • Tried re-registering listener on AppState change
  • Tested with both data-only and notification+data payloads

Issue persists on all attempts.

Any ideas what might be causing this or how to fix it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions