From 56b2d72dfc066e6099666c7d2c6cb906ea20cbf2 Mon Sep 17 00:00:00 2001 From: Sandipan Dey Date: Fri, 19 Jan 2024 23:55:55 +0530 Subject: [PATCH] chore: deep link all pages (#3012) --- .../push-notification/push-notification.tsx | 21 +++++++++---------- .../navigation-container-wrapper.tsx | 9 ++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/components/push-notification/push-notification.tsx b/app/components/push-notification/push-notification.tsx index 94c220bf0e..fe21c67ff9 100644 --- a/app/components/push-notification/push-notification.tsx +++ b/app/components/push-notification/push-notification.tsx @@ -1,13 +1,8 @@ import { useApolloClient } from "@apollo/client" import { useIsAuthed } from "@app/graphql/is-authed-context" -import { - PeopleStackParamList, - PrimaryStackParamList, -} from "@app/navigation/stack-param-lists" import { addDeviceToken, hasNotificationPermission } from "@app/utils/notifications" import messaging, { FirebaseMessagingTypes } from "@react-native-firebase/messaging" -import { useNavigation } from "@react-navigation/native" -import { StackNavigationProp } from "@react-navigation/stack" +import { useLinkTo } from "@react-navigation/native" import React, { useEffect } from "react" const circlesNotificationTypes = [ @@ -24,8 +19,8 @@ const circlesNotificationTypes = [ export const PushNotificationComponent = (): JSX.Element => { const client = useApolloClient() const isAuthed = useIsAuthed() - const primaryNavigation = useNavigation>() - const circlesNavigation = useNavigation>() + + const linkTo = useLinkTo() useEffect(() => { const showNotification = (remoteMessage: FirebaseMessagingTypes.RemoteMessage) => { @@ -42,8 +37,12 @@ export const PushNotificationComponent = (): JSX.Element => { typeof notificationType === "string" && circlesNotificationTypes.includes(notificationType) ) { - primaryNavigation.navigate("People") - setTimeout(() => circlesNavigation.navigate("circlesDashboard"), 200) + linkTo("/people/circles") + } + + const linkToScreen = remoteMessage.data?.linkTo ?? "" + if (typeof linkToScreen === "string") { + linkTo(linkToScreen) } } @@ -69,7 +68,7 @@ export const PushNotificationComponent = (): JSX.Element => { }) return unsubscribe - }, [circlesNavigation, primaryNavigation]) + }, [linkTo]) useEffect(() => { ;(async () => { diff --git a/app/navigation/navigation-container-wrapper.tsx b/app/navigation/navigation-container-wrapper.tsx index 74e7ae73fe..0a37a8ebb7 100644 --- a/app/navigation/navigation-container-wrapper.tsx +++ b/app/navigation/navigation-container-wrapper.tsx @@ -87,13 +87,22 @@ export const NavigationContainerWrapper: React.FC = ({ screens: { Home: "home", People: { + path: "people", screens: { circlesDashboard: "circles", }, }, + Earn: "earn", + Map: "map", }, }, sendBitcoinDestination: ":payment", + receiveBitcoin: "receive", + conversionDetails: "convert", + scanningQRCode: "scan-qr", + transactionDetail: { + path: "transaction/:txid", + }, }, }, getInitialURL: async () => {