invertase / notifee

⚛️ A feature rich notifications library for React Native.
https://notifee.app
Apache License 2.0
1.86k stars 225 forks source link

notifee.onBackgroundEvent only calls second time on iOS #1130

Open anoopmm opened 2 weeks ago

anoopmm commented 2 weeks ago

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.

LunatiqueCoder commented 1 week ago

Possible duplicate. See: