react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
740 stars 284 forks source link

OnClick event for scheduled push notification ios does not get triggered #259

Open dcx86 opened 3 years ago

dcx86 commented 3 years ago

I can't make the scheduled push notification on ios trigger a function to navigate the user to specific screen. It works on android both foreground and background but for ios it works only when the app is in foreground.

I've added this code on my App.tsx

useEffect(() => {  
 PushNotificationIOS.addEventListener('notification', onRemoteNotification)
  }, [])

  const onRemoteNotification = notification => {
    const isClicked = notification.getData().userInteraction === 1

    if (isClicked) {
      console.log('onRemoteNotification ~ isClicked')
    }
  }

Any help would be much appreciated!

dcx86 commented 3 years ago

Does anyone know what is going on here? Is there an issue with the library?

burak4ydin commented 3 years ago

Same problem... Any solution?

miksa1987 commented 3 years ago

Same for me... userInteraction is undefined. What's going on?

akinncar commented 2 years ago

TypeError: notification.getData is not a function right here

arunsunny07 commented 2 years ago

Same issue here

burak4ydin commented 2 years ago

Same problem... Any solution?

I've selected to use Firebase messaging, its handle event functions work on background and foreground without any problems ! 🤘🏻