react-native push-notification-ios geMes​​sage和getAlert返回未定义

问题描述

我正在使用本机0.62.2和@ react-native-community / push-notification-ios 1.4.0。我最近分别从0.61.51.0.3升级。现在,当我用户点击通知时,getMessagegetAlert API返回未定义。该通知将在电话上按预期显示。当我打印收到的通知时,会看到以下内容

{ _data: 
   { alarmId: '-MER20hCArS72IzmKDE1',uid: '-MBKyOBWjSzGtY-LPi4t'
   },_remoteNotificationCompleteCallbackCalled: false,_isRemote: undefined,_badgeCount: undefined,_sound: undefined,_alert: undefined,_title: undef2020-08-11 11:16:06.862887+0530 MyApp[1160:811760] SocketStream write error [0x280130fc0]: 1 32
ined,_category: 'i_am_up',_fireDate: undefined
}

_alert在以上数据中似乎未定义,但是该通知正确显示,并带有正确的警报消息。实际上,不仅警报而且未定义其他字段,例如fireDatesound。我不确定是什么原因引起的。

下面是安排通知的电话

PushNotificationIOS.schedulelocalnotification({
      fireDate: time,alertBody: alertBody,soundName: soundName,userInfo,category: category,repeatInterval: repeatInterval
})

P.S。我还在https://github.com/react-native-community/push-notification-ios/issues/169处针对此问题打开了一个github问题,其中还包含使用存储库中的示例项目进行复制的步骤。

解决方法

我已经在分支机构修复了此问题,并创建了一个拉取请求,最后合并了

https://github.com/nomi9995/push-notification-ios/tree/fix_169_issue

解决方案

现在您只需安装1.4.1

yarn add @react-native-community/push-notification-ios