Skip to content

[Bug]: react-native-onesignal: foregroundWillDisplay never fires in foreground (Expo 53, RN 0.79.5, v5.2.13) #250

@mehmetext

Description

@mehmetext

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

  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.

Logs

  • OneSignal.Debug.setLogLevel(LogLevel.Verbose) is enabled.
  • No foregroundWillDisplay logs 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); permissionChange fires normally.

Additional notes

  • click works as expected; the issue is only with foregroundWillDisplay.
  • 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

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions