Vladislav Stuk
Vladislav Stuk

Reputation: 5

react-native, Android Freshchat isFreshchatNotification not handling firebase remote message

I'm trying to integrate react-native-freshchat-sdk to react native app, but when firebase remote message is coming, freshchatNotification is 0, but it should be 1. Even if I pass notification to Freshchat.handlePushNotification nothing happens. I assume Freshchat.handlePushNotification should navigate the user to the conversation

Actual result

  1. freshchatNotification is 0 if it is fcm notification
  2. Freshchat.handlePushNotification(notification) does nothing

Expected result:

  1. freshchatNotification should be equal 1 if it is fcm notification
  2. Freshchat.handlePushNotification(notification) should navigate the user to the chat
import messaging from '@react-native-firebase/messaging'
import { Freshchat} from 'react-native-freshchat-sdk'
//...
useEffect(() => {
const unsubscribe = messaging().onMessage(notification => {
Freshchat.isFreshchatNotification(notification, (freshchatNotification) => {
    Freshchat.handlePushNotification(notification);
        if (freshchatNotification) {
            Freshchat.handlePushNotification(notification);
        } else {//...}
})
});
return unsubscribe
}, [])

See push notification payload below: enter image description here

Upvotes: 0

Views: 932

Answers (1)

sakivks
sakivks

Reputation: 36

Faced similar issue, worked by passing notification.data instead of direct notification object to Freshchat

useEffect(() => {
  const unsubscribe = messaging().onMessage(notification => {
  Freshchat.isFreshchatNotification(notification.data, (freshchatNotification) => {
    Freshchat.handlePushNotification(notification);
        if (freshchatNotification) {
            Freshchat.handlePushNotification(notification.data);
        } else {//...}
  })
  });
  return unsubscribe
}, [])

Upvotes: 2

Related Questions