Mishen Thakshana
Mishen Thakshana

Reputation: 1544

React Native Navigate to Particular Screen When Notification is Clicked in notifee

Is there any way to navigate to a screen after clicking on the notification in @notifee/react-native package?

    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?
    },
  },
});

Upvotes: 0

Views: 2390

Answers (1)

Xhirazi
Xhirazi

Reputation: 857

You can pass deeplink to notification data, And trigger it when notification press.

Like You pass

data:{deeplink:"/home"} 

in Push Notification

in onBackgroundEvent or onForegroundEvent

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

Where

import { useLinkToNative } from "@react-navigation/native";

const linkto = useLinkToNative();

for deeplink settings visit

Upvotes: 1

Related Questions