Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle callback when notification in background / terminate app #1037

Open
muslimmuda15 opened this issue May 21, 2024 · 4 comments
Open

Handle callback when notification in background / terminate app #1037

muslimmuda15 opened this issue May 21, 2024 · 4 comments

Comments

@muslimmuda15
Copy link

How to handle callback when Notificationin background?

I have put the code into index.js

// ...
Notifications.events().registerNotificationReceivedForeground(
  (notification, completion) => {
    console.log(
      `Notification received in foreground: ${notification.title} : ${notification.body}`,
    );
    completion({ alert: false, sound: false, badge: false });
  },
);

Notifications.events().registerNotificationReceivedBackground(
  (notification, completion) => {
    console.log(
      `Notification received in background: ${notification.title} : ${notification.body}`,
    );
    completion({ alert: false, sound: false, badge: false });
  },
);

The Notifications.events().registerNotificationReceivedForeground cllback in working well.
when I using Notifications.events().registerNotificationReceivedBackground the notif is successful to show in background / terminate, but I cannot getting any callback in my log.
Please help

@SwapnilRathore
Copy link

Same here , Please provide the fix

@coyotespike
Copy link

coyotespike commented Jul 18, 2024

I am observing the following:

  • On emulator, the notification is shown on foreground and background. HOWEVER, only registerNotificationReceivedForeground logs. registerNotificationReceivedBackground does not log.
  • A colleague testing on hardware sees notifications on foreground, not on background.

This is on v5.1.0. Really puzzling.

I have set <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> in all AndroidManifest, but this was already present in debug build and did not change anything.

I also ensured that playImplementation "com.google.firebase:firebase-messaging:23.3.1", not core, was present.

@coyotespike
Copy link

Just to bump this: this bug appears to be related to a lack of push notifications on Android API 33 and above, when the app is in the background. If anyone has any ideas I am happy to debug further!

@khalilpan
Copy link

khalilpan commented Sep 4, 2024

Same problem here in iOS. registerNotificationReceivedBackground does not log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants