点击@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"}
推送通知
在onBackgroundEvent
或onForegroundEvent
中
notifee.onForegroundEvent(({ type, detail }) => {
linkto(detail.notification.data.deeplink);
});
何处
import { useLinkToNative } from "@react-navigation/native";
const linkto = useLinkToNative();
有关深度链接设置,请访问