1
votes

I am making a react native app with oneSignal push notifications. I would like to just change the screen when a notification is received. I can do this if the app is in the foreground or if the notification was clicked. How would I trigger this if the app is closed or in the background?

import OneSignal from 'react-native-onesignal';

export default class Test extends Component {

  componentWillMount() {
    OneSignal.addEventListener('received', this.onReceived);
    OneSignal.addEventListener('opened', this.onOpened);
    OneSignal.addEventListener('registered', this.onRegistered);
    OneSignal.addEventListener('ids', this.onIds);
  }
1

1 Answers

1
votes

It seem like there is an issue with background notifications and onReceived. Check this: link Setting content available to true and

onReceived = (receivedNotif) => {
}

works for me when the app is active or in the background but not when the app is closed. When the app is closed I receive them in the notification center but not in the app.