From 587d41950233860e96f335fed3304d8407707fad Mon Sep 17 00:00:00 2001 From: herrrta <73949927+herrrta@users.noreply.github.com> Date: Fri, 21 Mar 2025 20:52:22 -0400 Subject: [PATCH] feat: new notification deep links --- app/_layout.tsx | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/app/_layout.tsx b/app/_layout.tsx index f68f0393..301433ae 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -356,7 +356,39 @@ function Layout() { responseListener.current = Notifications?.addNotificationResponseReceivedListener( (response: NotificationResponse) => { - console.log("Notification interacted with", response); + // Currently the notifications supported by the plugin will send data for deep links. + const data = response.notification.request.content.data; + + if (data && Object.keys(data).length > 0) { + const type = data["type"].toLower(); + const itemId = data["id"]; + + switch (type) { + case "movie": + router.push(`/(auth)/(tabs)/home/items/page?id=${itemId}`) + break; + case "episode": + const episodeId = data.id; + + // We just clicked a notification for an individual episode. + if (episodeId) { + router.push(`/(auth)/(tabs)/home/items/page?id=${itemId}`) + } + // summarized season notification for multiple episodes. Bring them to series season + else { + const seriesId = data.seriesId; + const seasonIndex = data.seasonIndex; + + if (seasonIndex) { + router.push(`/(auth)/(tabs)/home/series/${seriesId}?seasonIndex=${seasonIndex}`) + } + else { + router.push(`/(auth)/(tabs)/home/series/${seriesId}`) + } + } + break; + } + } }, );