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: Notifications autmatically clear on iOS #3270

Closed epicshaggy closed 3 years ago

epicshaggy commented 3 years ago

Bug Report

Capacitor Version

Latest Dependencies:

  @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)

iOS

Current Behavior

When the application is closed (removed from app switcher) if I tap a notification and there are already two or more notifications the app is launched and notification is handled but the other notifications are removed from notification center.

Expected Behavior

When the application is closed (removed from app switcher) if I tap a notification and there are already two or more notifications the app is launched and notification is handled and the other notifications should remain on the notification center until tapped by user or removed by the developer.

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

jcesarmobile commented 3 years ago

I can't reproduce on @capacitor/ios 3 beta 2 and @capacitor/local-notifications 0.4.0

epicshaggy commented 3 years ago

I forgot about this. It was my bad, I was setting the app's icon badge to 0 and that was clearing notifications from notification center.

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.