Android: onBackgroundEvent not fired when quick action is pressed

See original GitHub issue

I’ve a notification with two actions (accept call/ reject call).

 android: {
        channelId: callChannelId,
        category: AndroidCategory.CALL,
        circularLargeIcon: true,

        color: AndroidColor.BLUE,

        // Recommended to set importance to high

        importance: AndroidImportance.HIGH,
        ongoing: true,
        fullScreenAction: {
          id: 'incoming-call',
        },
        largeIcon: largeIcon,

        // smallIcon: 'name-of-a-small-icon', // optional, defaults to 'ic_launcher'.

        actions: [
          {
            title: 'Reject',
            pressAction: { id: NOTIFICATION_ACTIONS_ID.cancelIncomingCall },
          },
          {
            title: 'Accept',
            pressAction: { id: NOTIFICATION_ACTIONS_ID.acceptIncomingCall, launchActivity: 'default' },
          },
        ],
        badgeCount: 1,
        timeoutAfter: ONE_MINUTE,
        autoCancel: false,
      },

handleOnForegroundEvent works fine.
And now I’m trying to add handleOnForegroundEvent: The notification get displayed in killed state and handleOnForegroundEvent fired once then when I pressed I can’t get wich action get pressed because onBackgroundEvent not fired when I pressed.

notifee.onBackgroundEvent(async ({ type, detail }) => {

  const { notification, pressAction } = detail;
    

    if (type === EventType.ACTION_PRESS) {
      if (pressAction.id === NOTIFICATION_ACTIONS_ID.acceptIncomingCall || type === EventType.PRESS) {
        // accept call
        incomingCallNotifications.handleAcceptCall(notification);
      } else {
        incomingCallNotifications.handleRejectCall(notification);
      }

      return;
    }
});

Package.json

"@notifee/react-native": "^5.0.3",
"react-native": "0.67.4",

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:7
  • Comments:67 (30 by maintainers)

github_iconTop GitHub Comments

11reactions
lpatruncommented, Oct 27, 2022

Has anybody made any progress with onBackgroundEvent for Android >= 12? I am trying to understand the issue but not quite sure where to start.

10reactions
helenafordcommented, Dec 5, 2022

Massive thanks to @mieszko4 for fixing this issue! Released in 7.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native navigate after a notification press - Stack Overflow
We've tried using the useNavigation() in the notifee.onBackgroundEvent() but we keep getting an Invalid hook call. When we try to pass the ...
Read more >
NotificationAndroid - Notifee
Quick Actions enable users to interact with your application directly from the notification body, providing an overall greater user experience. View the Quick ......
Read more >
force:closeQuickAction - documentation - Salesforce Developers
To close a quick action panel, usually in response to completing or canceling the action, run $A.get("e.force:closeQuickAction").fire(); .
Read more >
React-native: A journey through push notification and quick ...
A Journey through push notifications and quick actions in React-native ... listener in your application to capture the press on our 2 actions...
Read more >
Push Notification using Notifee in React Native - YouTube
In this video we are going to implement Push Notification using Notifee library in React Native. Notifee is a great library to implement ......
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