Skip to content

Commit 09c5203

Browse files
committed
Cleanup effects
1 parent d3d3142 commit 09c5203

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

packages/expo/src/modules/push/KnockExpoPushNotificationProvider.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,25 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
211211
customNotificationHandler ?? defaultNotificationHandler,
212212
});
213213

214+
const response = Notifications.getLastNotificationResponse();
215+
if (response?.notification) {
216+
knockClient.log(
217+
"[Knock] Expo Push Notification was interacted with (initial)",
218+
);
219+
updateKnockMessageStatusFromNotification(
220+
response.notification,
221+
"interacted",
222+
);
223+
notificationTappedHandler(response);
224+
}
225+
}, [
226+
customNotificationHandler,
227+
knockClient,
228+
notificationTappedHandler,
229+
updateKnockMessageStatusFromNotification,
230+
]);
231+
232+
useEffect(() => {
214233
if (autoRegister) {
215234
registerForPushNotifications()
216235
.then(() => {
@@ -268,18 +287,16 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
268287
notificationReceivedSubscription.remove();
269288
notificationResponseSubscription.remove();
270289
};
271-
272-
// TODO: Remove when possible and ensure dependency array is correct
273-
// eslint-disable-next-line react-hooks/exhaustive-deps
274290
}, [
275291
registerForPushNotifications,
276292
notificationReceivedHandler,
277293
notificationTappedHandler,
278-
customNotificationHandler,
279294
autoRegister,
280295
expoPushToken,
281296
knockExpoChannelId,
282297
knockClient,
298+
registerPushTokenToChannel,
299+
updateKnockMessageStatusFromNotification,
283300
]);
284301

285302
return (

0 commit comments

Comments
 (0)