react-native-notifications: [ANDROID] registerNotificationReceivedBackground is not triggered when the app is killed.

Notifications.events().registerNotificationReceivedBackground() is triggered when the app is in the foreground and in the background but not when the app is killed.

'react-native': 0.61
'react-native-notificiations': 3.1.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 18 (4 by maintainers)

Most upvoted comments

Exactly

When App is killed you need to obtain the payload with this:

async componentDidMount() {
    const notification: Notification = await Notifications.getInitialNotification()
    console.log('initial', notification)
  }

In my case notification object was always thrown undefined… 😢😢😢😢

My Code

useEffect(()=>{
 Notifications.getInitialNotification().then(notification=>{
  console.log(notification);
 }).catch(error=>{
 console.log(error);
});
},[]);