Skip to content

[Bug]: Notifications being received but not displaying in the device. Until I reboot #1864

@migueacastro

Description

@migueacastro

What happened?

I set up the One Signal SDK on an expo proyect like this, loading inside a layout useEffect hook and adding an event Listener for each notification that might be received. inside the device.

Below you might see my implementation and the logs I receive. Curiously notifications might be received after rebooting my device and using the app. But after 5 minutes it stops working. This happens in Miui with Android 14 and 15. I also used an Emulator with Android 16 and it happened the described behaviour.

Steps to reproduce?

1. Install OneSignal Expo package and OneSignal React Native package
2. Write this inside a _layout.tsx useEffect Hook. ` OneSignal.initialize(ONE_SIGNAL_APP_ID);
    OneSignal.Notifications.requestPermission(true);

    OneSignal.Notifications.addEventListener(
      "foregroundWillDisplay",
      (event) => {
        if (debug) console.log(event.notification);

        onReceiveNotification?.(event); // Llama al hook si está definido
        return event.getNotification();
      }
    );`

What did you expect to happen?

I expected it to receive the notification instantly or at least 2 minutes later.

React Native OneSignal SDK version

5.2.14

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

{"actionButtons": undefined, "additionalData": undefined, "androidNotificationId": 816145182, "bigPicture": undefined, "body": "This is a test and proves that the device received the notification", "collapseId": undefined, "fromProjectNumber": "605381231729", "groupKey": undefined, "groupMessage": undefined, "largeIcon": undefined, "launchURL": undefined, "ledColor": undefined, "lockScreenVisibility": 1, "notificationId": "7851bab3-1cff-430c-8a4b-ec4d22ac53ab", "priority": 5, "rawPayload": "{\"google.delivered_priority\":\"high\",\"google.sent_time\":1763999684197,\"google.ttl\":259200,\"google.original_priority\":\"high\",\"custom\":\"{\\\"i\\\":\\\"7851bab3-1cff-430c-8a4b-ec4d22ac53ab\\\",\\\"a\\\":{}}\",\"google.product_id\":111881503,\"pri\":\"5\",\"vis\":\"1\",\"from\":\"605381231729\",\"alert\":\"This is a test and proves that the device received the notification\",\"title\":\"This is a test\",\"google.message_id\":\"0:1763999684201586%45026d02f9fd7ecd\",\"google.c.sender.id\":\"605381231729\"}", "smallIcon": undefined, "smallIconAccentColor": undefined, "sound": undefined, "title": "This is a test"}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions