if app is in foreground i'm using FCM.on(FCMEvent.Notification, async (notif) => { to get notifications for background and foreground. If it is from background when i click action method works fine. but if the app is in foreground and receive a notification then it will directly do its action manually without taping on the nottification. My exact function is something like
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
console.log("INITIAL NOTIFICATION FINAL", JSON.stringify(notif));
if (Platform.OS === 'ios') {
if (notif === undefined) {
this._navigateToMainView()
} else {
if (notif.type === '1') {
this.props.navigation.navigate('chatList')
} else if (notif.type === '2') {
this.props.navigation.navigate('chatList')
} else if (notif.type === '3') {
this.props.navigation.navigate('chatList')
console.debug('data' + JSON.stringify(notif))
} else if (notif.type === '4') {
this.props.navigation.navigate('contactRequest')
} else if (notif.type === '5') {
console.log('notifi 5')
let arr = JSON.parse(notif.finalArray)
console.log(arr.roomId)
if (arr.videoCallRequest) {
this.props.callStatus(arr.roomId)
this.props.navigation.navigate('VideoCallAcceptOrReject', { senderName: arr.senderFullname, roomId: arr.roomId })
}
if (arr.isAccept === 'true') {
console.log('accept true')
this.props.callStatus(arr.roomId)
this.props.navigation.navigate('videoCall', { roomId: arr.roomId })
} else if (arr.isAccept === 'false') {
console.log('accept false')
this.props.navigation.navigate('yourMatches', { roomId: arr.roomId })
}
console.log('video' + JSON.stringify(notif))
}
}
} else if (Platform.OS !== 'ios') {
if (notif.opened_from_tray === 1) {
this._navigateToMainView()
}
}
Hi,
if app is in foreground i'm using FCM.on(FCMEvent.Notification, async (notif) => { to get notifications for background and foreground. If it is from background when i click action method works fine. but if the app is in foreground and receive a notification then it will directly do its action manually without taping on the nottification. My exact function is something like this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => { console.log("INITIAL NOTIFICATION FINAL", JSON.stringify(notif));