0

我正在尝试集成react-native-freshchat-sdk以响应本机应用程序,但是当 Firebase 远程消息到来时,freshchatNotification 为 0,但它应该为 1。即使我传递notification给 Freshchat.handlePushNotification 也没有任何反应。我假设 Freshchat.handlePushNotification 应该将用户导航到对话

实际结果

  1. 如果是 fcm 通知,freshchatNotification 为 0
  2. Freshchat.handlePushNotification(notification) 什么都不做

预期结果:

  1. 如果是 fcm 通知,freshchatNotification 应该等于 1
  2. Freshchat.handlePushNotification(notification) 应该将用户导航到聊天
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
}, [])

请参阅下面的推送通知有效负载: 在此处输入图像描述

4

1 回答 1

0

面临类似问题,通过传递notification.data而不是直接通知对象来工作Freshchat

useEffect(() => {
  const unsubscribe = messaging().onMessage(notification => {
  Freshchat.isFreshchatNotification(notification.data, (freshchatNotification) => {
    Freshchat.handlePushNotification(notification);
        if (freshchatNotification) {
            Freshchat.handlePushNotification(notification.data);
        } else {//...}
  })
  });
  return unsubscribe
}, [])
于 2021-10-05T03:19:03.093 回答