invertase / notifee

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

Stop notification sliding back into header after interaction? #1052

Closed James-Clark12 closed 3 months ago

James-Clark12 commented 5 months ago

Hey, I have the notifee notifications working nicely in android except whenever the app is in the background and I interact with the notification it slides back up into the notification drawer or to be more accurate the whole notification drawer collapses back up. The interaction callback is called but I want the drawer and notification to remain visible so the user can press the interaction multiple times (it increments a timer). The notification is not cleared just updated.

To be clear I am not trying to prevent the notification from being dismissed but have added the properties "ongoing: false" and "autoCancel: false" anyway. I just want the drawer to stay open.

The interactions execute some callback which in turn calls a function that updates the notification using this function:

export async function updateNotification(
    notificationData: NotificationDataType,
) {
    await notifee.displayNotification({
        id: NOTIFICATION_ID,
        title: notificationData.title,
        body: notificationData.body,
        android: {
            ongoing: true,
            autoCancel: false,
            channelId: notificationData.channelId,
            actions: notificationData.actions,
            pressAction: {
                id: 'default',
            },
        },
    });
}

I think this code is fine and not causing the notification/ drawer to slide up so I'm really not sure what is causing it.

I request the channel in the correct way too I believe:

    useEffect(() => {
        /**On mount we need to get permission to show notifications and also select a channel
         * for notifications to show on (android thing)
         */
        const requestNotificationPermission = async () => {
            await notifee.requestPermission();
            const newChannelId = await notifee.createChannel({
                id: 'default',
                name: 'Default Channel',
                importance: AndroidImportance.HIGH,
            });
            setChannelId(newChannelId);
        };
        requestNotificationPermission();
    }, []);

Any suggestions as to what is happening? I'd be very grateful. Otherwise I have found this to be a great library.

github-actions[bot] commented 4 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

kasparas-ban commented 1 month ago

I have the same issue - all notification actions automatically close the notification drawer. It seems this is a hardcoded functionality within the Notifee library. Which is confusing because I can see the hideNotificationDrawer() function in the API, but no way to do the opposite.