在notife中单击通知时,React Native导航到特定屏幕



点击@notifee/react-native包中的通知后,有没有方法导航到屏幕?

const channelId = await notifee.createChannel({
id: 'default',
name: 'Default Channel',
});
await notifee.displayNotification({
title: 'Notification Title',
body: 'Main body content of the notification',
android: {
channelId,
smallIcon: 'ic_launcher',
pressAction: {
id: 'default',
//Anything to add here?
},
},
});

您可以将deeplink传递给通知数据,并在通知按下时触发它。

就像你通过

data:{deeplink:"/home"} 

推送通知

onBackgroundEventonForegroundEvent

notifee.onForegroundEvent(({ type, detail }) => {
linkto(detail.notification.data.deeplink);
});

何处

import { useLinkToNative } from "@react-navigation/native";
const linkto = useLinkToNative();

有关深度链接设置,请访问

最新更新