-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
BugSomething isn't workingSomething isn't working
Description
What happened?
When the app is in the foreground, the foregroundWillDisplay event never fires. Sending multiple test pushes in the same session makes no difference; the handler does not run and no logs appear.
Code in use
- OneSignal init and listeners (
app/_layout.tsx):
const initializeOneSignal = async () => {
if (!process.env.EXPO_PUBLIC_ONESIGNAL_APP_ID) {
throw new Error("ONESIGNAL_APP_ID is not set");
}
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize(process.env.EXPO_PUBLIC_ONESIGNAL_APP_ID);
OneSignal.Notifications.requestPermission(true);
OneSignal.Notifications.addEventListener("permissionChange", (event) => {
console.log("Notification permission changed:", event);
});
OneSignal.Notifications.addEventListener("click", (event) => {
console.log("Notification clicked:", event);
});
OneSignal.Notifications.addEventListener(
"foregroundWillDisplay",
(event) => {
console.log("Notification foreground will display:", event);
}
);
};Note: Even though the foregroundWillDisplay listener is added in the init, no related log appears in the console while the app is in the foreground.
Steps to reproduce
- Keep the app open in the foreground.
- Send a simple text push from the OneSignal Dashboard (no silent/data-only).
- Observe the console: no
foregroundWillDisplaylogs; the handler does not run anddisplay()is not called. - Repeat several times; it still never fires.
Logs
OneSignal.Debug.setLogLevel(LogLevel.Verbose)is enabled.- No
foregroundWillDisplaylogs appear at all in the foreground. Other events (click,permissionChange) do fire and log correctly.
Environment
- Expo: 53.0.20 (managed)
- React Native: 0.79.5
- React: 19.0.0
- react-native-onesignal: 5.2.13
- onesignal-expo-plugin: 2.0.3
- Platform: iOS (real device and/or simulator)
- Permissions: Granted via
requestPermission(true);permissionChangefires normally.
Additional notes
clickworks as expected; the issue is only withforegroundWillDisplay.- No custom notification filters or conditions; the listener is added right after initialization.
- I can provide a minimal repro if needed. Is this a known issue or is there any required additional configuration?
Steps to reproduce?
1. Keep the app open in the foreground.
2. Send a simple text push from the OneSignal Dashboard (no silent/data-only).
3. Observe the console: no foregroundWillDisplay logs; the handler does not run and display() is not called.
4. Repeat several times; it still never fires.What did you expect to happen?
Every notification received while the app is in the foreground should trigger foregroundWillDisplay.
OneSignal Expo SDK version
"onesignal-expo-plugin": "^2.0.3"
"react-native-onesignal": "^5.2.13"
Platform
Android
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working