我想实现与Firebase发送的推送通知进行交互时打开特定屏幕的功能。我的理解是,我需要使用getInitialNotification()
及更低版本中可用的react-native-firebase v5
函数,但由于Notifications包尚未准备就绪,因此react-native-firebase v6
中尚不可用。
除其他事项外,到目前为止,我已经尝试设置Cloud Messaging程序包中可用的后台消息处理程序,但是它似乎不适用于不是data-only
消息的内容:
Firebase.messaging().setBackgroundMessageHandler(async (remoteMessage) => {
await storeJSONData('notification',JSON.stringify(remoteMessage));
});
我应该降级到react-native-firebase v5
以便从Notifications包中使用他们的getInitialNotification()
,还是我有其他更好的选择,例如甚至使用android原生代码?