question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: when the App is closed completely the notificationActionPerformed listener is not fired

See original GitHub issue

Plugin(s):

Platform(s):

  • iOS

Current behavior: When the App is closed (killed) completely and a push notification is sent, you open it from the notifications center and the notificationActionPerformed listener is not fired. I don’t know if notificationReceived is being called, I see no logs.

Expected behavior: notificationActionPerformed should be called when the app is closed completely.

Steps to reproduce: Close the app completely, send a notification and try to open the notification from the notifications center.

Related code:

    FirebaseMessaging.addListener('notificationReceived', event => {
      console.log('notificationReceived', {event});
    });

    FirebaseMessaging.addListener('notificationActionPerformed', event => {
      console.log('notificationActionPerformed', {event});
    });

Payload being sent to FCM API:

{
  "to":"/topics/example",
  "priority":"high",
  "notification":{
    "title":"Hi",
    "body":"Testing here"
  },
  "data":{
    "title":"Hi",
    "body":"Testing here"
  }
}

AppDelegate:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
      NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
    }

    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
      NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
    }
    
    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        NotificationCenter.default.post(name: Notification.Name.init("didReceiveRemoteNotification"), object: completionHandler, userInfo: userInfo)
    }

image

Capacitor config:

PushNotifications: {
      presentationOptions: ["badge", "sound", "alert"],
    },

The notification is displayed correctly on the phone and in the notification center.

Other information: My goal is to be able to open a screen when you tab a notification from the notifications center. Right now, is not working because notificationActionPerformed is not being called.

Imagine when you tab on a notification from WhatsApp and you are redirected to a screen that contains your conversation.

I don’t know if this is a bug or a known limitation where we don’t have a workaround yet.

Others issues that can be related or not:

  • No sound is played by default. Not even the iOS default one.
  • No badge count is being set above the App icon.

I have read:

Any help is appreciated.

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
carlosskcommented, Aug 24, 2022

I have the same issue, any idea about it?

1reaction
RRGT19commented, Oct 3, 2022

@robingenz That version is working good from all points of view, app open/closed/killed, etc… 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

pushNotificationActionPerformed listener not firing on iOS ...
When a notification comes in, and it is clicked, the app opens as expected, but the pushNotificationActionPerformed listener does not fire. For ...
Read more >
"push Notification Action Performed" listener not triggered all ...
Sometimes the “pushNotificationActionPerformed” listener it's not triggered. When application it's closed, after we tap on a notification, ...
Read more >
Expo notification doesnt fire method when app is killed/closed
The problem is that the useEffect() get called too late after the app has finished initializing. Therefore the listener is not added before ......
Read more >
Firebase Push Notification in Ionic React app using Capacitor
Learn how to implement firebase push notifications in Ionic-React apps using Capacitor ... This listener will fire when your registration is not successful....
Read more >
Activity - Android Developers
It is possible if a new non-full-sized or transparent activity has focus on top ... This hook is called whenever the context menu...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found