【问题标题】:react-native, Android Freshchat isFreshchatNotification not handling firebase remote messagereact-native,Android Freshchat isFreshchatNotification 未处理 Firebase 远程消息
【发布时间】:2021-05-21 06:23:50
【问题描述】:

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

实际结果

  1. freshchatNotification 如果是 fcm 通知则为 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
}, [])

请参阅下面的推送通知负载:

【问题讨论】:

  • 我将 notification.data 传递给 Freshchat.isFreshchatNotification、Freshchat.handlePushNotification 并且一切正常

标签: react-native freshdesk


【解决方案1】:

面临类似问题,通过将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
}, [])

【讨论】:

    猜你喜欢
    • 2023-01-05
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 2022-12-05
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    相关资源
    最近更新 更多