@@ -221,6 +221,25 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
221221 customNotificationHandler ?? defaultNotificationHandler ,
222222 } ) ;
223223
224+ const response = Notifications . getLastNotificationResponse ( ) ;
225+ if ( response ?. notification ) {
226+ knockClient . log (
227+ "[Knock] Expo Push Notification was interacted with (initial)" ,
228+ ) ;
229+ updateKnockMessageStatusFromNotification (
230+ response . notification ,
231+ "interacted" ,
232+ ) ;
233+ notificationTappedHandler ( response ) ;
234+ }
235+ } , [
236+ customNotificationHandler ,
237+ knockClient ,
238+ notificationTappedHandler ,
239+ updateKnockMessageStatusFromNotification ,
240+ ] ) ;
241+
242+ useEffect ( ( ) => {
224243 if ( autoRegister ) {
225244 registerForPushNotifications ( )
226245 . then ( ( ) => {
@@ -254,16 +273,6 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
254273 notificationReceivedHandler ( notification ) ;
255274 } ) ;
256275
257- const response = Notifications . getLastNotificationResponse ( ) ;
258- if ( response ?. notification ) {
259- knockClient . log ( "[Knock] Expo Push Notification was interacted with" ) ;
260- updateKnockMessageStatusFromNotification (
261- response . notification ,
262- "interacted" ,
263- ) ;
264- notificationTappedHandler ( response ) ;
265- }
266-
267276 const notificationResponseSubscription =
268277 Notifications . addNotificationResponseReceivedListener ( ( response ) => {
269278 knockClient . log ( "[Knock] Expo Push Notification was interacted with" ) ;
@@ -278,18 +287,16 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
278287 notificationReceivedSubscription . remove ( ) ;
279288 notificationResponseSubscription . remove ( ) ;
280289 } ;
281-
282- // TODO: Remove when possible and ensure dependency array is correct
283- // eslint-disable-next-line react-hooks/exhaustive-deps
284290 } , [
285291 registerForPushNotifications ,
286292 notificationReceivedHandler ,
287293 notificationTappedHandler ,
288- customNotificationHandler ,
289294 autoRegister ,
290295 expoPushToken ,
291296 knockExpoChannelId ,
292297 knockClient ,
298+ registerPushTokenToChannel ,
299+ updateKnockMessageStatusFromNotification ,
293300 ] ) ;
294301
295302 return (
0 commit comments