Please provide the following:
- SDK Version: 40
- Platforms(Android/iOS/web/all): iOS
- 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]
);