Skip to content

notifee.onBackgroundEvent only calls second time on iOS #1130

@anoopmm

Description

@anoopmm

I have implemented categories using Notifee.setNotificationCategories

await notifee.setNotificationCategories([
    {
      id: 'actions',
      actions: [
        {
          id: 'yes',
          title: 'Yes',
        },
        {
          id: 'no',
          title: 'No',
        },
        {
          id: 'reply', // Action with input
          title: 'Reply',
          input: {
            placeholder: 'Type your reply here...', // Placeholder text for input field
            buttonText: 'Send', // Text for the action button
          },
        },
      ],
    },
  ]);

I need to call an API once the user types something in text box and clicks on reply

notifee.onBackgroundEvent(({type, detail}) => {
if (detail.pressAction.id === 'reply') {
  const userInput = detail.input; // This is the input text entered by the user
  console.log('User input:', userInput);
  postData(userInput, detail.notification.data.conversation_id);//api call
}
});

in the above function post data should call an API with user input

It only works the second time if the app is in a quit state. How can I make it work on the first notification?
I think the app is possibly being woken up by the first notification in the background, and it works on the second notification because the app was already woken up by the first one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions