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

capacitor-firebase/messaging notificationReceived called instead of notificationActionPerformed #2291

Closed
stevecohenfr opened this issue Jan 6, 2025 · 2 comments

Comments

@stevecohenfr
Copy link

Bug Report

Plugin(s)

[capacitor] @capacitor-firebase/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] [email protected]
[capacitor] [email protected]

Capacitor Version

💊   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

Platform(s)

  • iOS

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.

Code Reproduction

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 Technical Details

Tested on iPhone 13 Pro Max Xcode Emulator and real device

@Ionitron
Copy link
Collaborator

This issue needs more information before it can be addressed.
In particular, the reporter needs to provide a minimal sample app that demonstrates the issue.
If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks!
Ionitron 💙

@Ionitron
Copy link
Collaborator

Ionitron commented Feb 6, 2025

It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

Have a great day!
Ionitron 💙

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

No branches or pull requests

3 participants