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

bug: notificationReceived called instead of notificationActionPerformed #793

Open
5 of 17 tasks
stevecohenfr opened this issue Jan 8, 2025 · 1 comment
Open
5 of 17 tasks
Labels

Comments

@stevecohenfr
Copy link

stevecohenfr commented Jan 8, 2025

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Functions
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Version

6.3.1

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

When my app is in the background and receives a notification, the notificationReceived event is correctly triggered with the expected data.

However, when I click on the notification, the notificationReceived event is triggered again instead of the notificationActionPerformed event. This behavior prevents me from handling notification actions as expected.

Expected behavior

notificationReceived should be triggered when the notification is received in the background.
notificationActionPerformed should be triggered when the notification is clicked.

Reproduction

n/a

Steps to reproduce

async addListeners() {
    FirebaseMessaging.removeAllListeners().then(async () => {
      console.log('[Notifications Push] Listening "tokenReceived" event');
      await FirebaseMessaging.addListener('tokenReceived', async event => {
        console.info('[Notifications Push] Registration token: ', event.token);
        const addResponse = await this.fcmService.addFcmToken(event.token);
        console.log('[Notifications Push] Ajout du token réussi :', addResponse);
      });

      console.log('[Notifications Push] Listening "notificationReceived" event');
      await FirebaseMessaging.addListener('notificationReceived', event => {
        console.log('[Notifications Push] notificationReceived', JSON.stringify(event));
        const data = (event.notification.data as any);
        this.handleNotificationClicked(data);
      });

      console.log('[Notifications Push] Listening "notificationActionPerformed" event');
      await FirebaseMessaging.addListener('notificationActionPerformed', event => {
        console.log('[Notifications Push] notificationActionPerformed', {event});
        const data = (event.notification.data as any);
        this.handleNotificationClicked(data);
      });
    });
  }

addListeners is called is the ngAfterViewInit from my main component

Other information

No response

Capacitor doctor

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 6.2.0
  @capacitor/core: 6.2.0
  @capacitor/android: 6.2.0
  @capacitor/ios: 6.2.0

Installed Dependencies:

  @capacitor/cli: 5.7.5
  @capacitor/core: 5.7.5
  @capacitor/android: 5.7.5
  @capacitor/ios: 5.7.5

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@stevecohenfr stevecohenfr added bug/fix Something isn't working needs: triage labels Jan 8, 2025
@robingenz
Copy link
Member

Thank you for reporting that. I will take a look as soon as i have time. Feel free to create a PR if you would like to take a closer look.

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

No branches or pull requests

2 participants