Skip to content

[Android] onNotification not called when application is closed #13

@avencat

Description

@avencat

Hi,
I'm trying to add a badge when I receive a notification on Android but I have an issue, indeed, the onNotification is not triggered when app wasn't launched at all. So when I receive the first notification and the app is not launched, I can see in the Chrome debugger that the app launches (silently, it doesn't open) but onNotification is not triggered. After that, when I receive another notification and the app is already silently launched, then, the onNotification is triggered...

For the record, I'm trying to PushNotification.setApplicationBadgeNumber() each time I receive a notification but if onNotification is not called the first time, I can't do it... I also tried to put:

console.log('appStart');
PushNotification.appStart();

in a setTimeout like this:

setTimeout(() => {
  console.log('appStart');
  PushNotification.appStart();
}, 10);

but then, the timeout is reached only when I manually launch the app...

If anyone has another solution to set the badge on Android even when I receive only one notification, please let me know! :)

RN VERSION: 0.55.3
LIB VERSION: Master (#767d043f15fe7daf8639b4a5fbcba6fca960d793)
PHONE: Xiaomi Redmi Note 4X
PLATFORM: Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions