useLastNotificationResponse triggers twice

Please provide the following:

  1. SDK Version: 40
  2. Platforms(Android/iOS/web/all): iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I didn’t test on android. I’m on ios doing dev. Using useLastNotificationResponse seems to trigger twice for each notification I tap. Screenshot below shows it console logs notification, undefined, then notification again. Does anyone else see this behavior?

My code is very basic:

// stored global level
const triggerCntById = {}



const lastNotificationResponse = Notifications.useLastNotificationResponse();
useEffect(
        () => {
            console.log(
                'lastNotificationResponse changed, it is now:',
                lastNotificationResponse
            );
            if (!lastNotificationResponse) return;

            const id = lastNotificationResponse.notification.request.identifier;
            if (triggerCntById[id]) {
                triggerCntById[id]++;
                console.warn(
                    'Already triggered handler for notification.',
                    id,
                    triggerCnt: triggerCntById[id],
                }
            );
            return;
        } else {
            triggerCntById[id] = 1;
        }
    },
    [lastNotificationResponse]
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.