react-native-push-notification: onNotification not fired when app is minimised
In my project, onNotification function works fine when the app is in foreground. It even gets fired when the app has been closed and user opens the app by clicking on the notification. But when the app is minimised, on receiving notification and clicking it, the app opens but onNotification function is not being called. Here is my app.js:
export default class App extends Component{
constructor(props) {
super(props);
this.state = {
senderId: appConfig.senderID,
notiType: 'default'
};
this.notif = new NotifService(
this.onRegister.bind(this),
this.onNotif.bind(this),
);
}
onRegister(token) {
this.setState({registerToken: token.token, fcmRegistered: true});
}
onNotif(notif) {
console.log(notif);
if(notif.type != undefined) this.setState({notiType: notif.type});
}
componentDidMount(){
this.notif.configure(
this.onRegister.bind(this),
this.onNotif.bind(this),
this.state.senderId,
);
}
render(){
return (
<NavigationContainer>
{StackScreen(this.state.notiType)}
</NavigationContainer>
);
}
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15
Ok thanks a lot! Atleast this one got fixed automatically. 😅 I will close this issue.