-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
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
- Set up a foreground listener:
useEffect(() => {
const unsubscribe = messaging().onMessage(async (message) => {
console.log('Foreground message:', message);
});
return () => unsubscribe();
}, []);- Send notification while app is in foreground β works
- Put app in background, send notification β works
- Bring app back to foreground, send notification β doesn't work
- 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?