ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
https://capacitorjs.com
MIT License
11.47k stars 977 forks source link

bug: Notification listeners stop listening after a few minutes #3272

Closed epicshaggy closed 1 year ago

epicshaggy commented 3 years ago

Bug Report

Capacitor Version

@capacitor/cli: 2.2.1

  @capacitor/core: 2.2.1

  @capacitor/android: 2.2.1

  @capacitor/electron: 2.2.1

  @capacitor/ios: 2.2.1

Installed Dependencies:

  @capacitor/electron not installed

  @capacitor/cli 2.2.0

  @capacitor/ios 2.2.0

  @capacitor/core 2.2.0

  @capacitor/android 2.2.0

[success] Android looking great! πŸ‘Œ
  Found 4 Capacitor plugins for ios:
    application-icon-badge (0.0.1)
    capacitor-file-picker (0.0.1)
    capacitor-native-biometric (0.1.1)
    capacitor-sharing (0.1.2)
[success] iOS looking great! πŸ‘Œ

Platform(s)

Android, iOS

Current Behavior

When the application is in the foreground and the user navigates away from the application and leaves it in the background for a minute or so and taps a notification, the app will launch as if it were launched normally, pushNotificationActionPerformed doesn't fire.

Expected Behavior

After the application is in the background for a minute or so and the user taps a notification, pushNotificationActionPerformed should fire.

Code Reproduction

PushNotifications.addListener(
              "pushNotificationActionPerformed",
              async (notification: PushNotificationActionPerformed) => {
                console.log(
                  "notification action: " + JSON.stringify(notification)
                );
                // execute route depending on action
                if (notification != null && notification !== undefined) {
                  const category = notification.notification.data.Category;

                  switch (category) {
                    case "SECURE_MESSAGE":
                      this.performNotificationAction(
                        notification.notification.data.MessageID,
                        notification.actionId
                      );
                      break;
                    case "SHARED_DOCUMENT":
                      this.performDocumentNotificationAction(
                        notification.notification.data.DocumentID
                      );
                      break;
                  }
                }
              }
            );

Other Technical Details

npm --version output: 6.14.1

node --version output: v12.16.1

pod --version output (iOS issues only): 1.9.1

Additional Context

The method which registers push notifications and adds the listeners is inside my authentication service. This method fires once the user has logged in.

Ionitron commented 1 year ago

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron πŸ’™

Ionitron commented 1 year ago

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 πŸ’™

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.