Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ThemeProvider } from '@react-navigation/native'
import { Slot } from 'expo-router'

import { AbsoluteFullFill, Loader } from '~components'
import { useAuth, useNavigationTheme } from '~hooks'
import { useAuth, useNavigationTheme, useRouterNotifications } from '~hooks'
import { Providers } from '~providers'

export const unstable_settings = {
Expand All @@ -13,6 +13,8 @@ const Layout = () => {
const { isSignedIn } = useAuth()
const { navigationTheme } = useNavigationTheme()

useRouterNotifications() // TODO: check if handling notification deeplinks works correctly

if (isSignedIn === null) {
return (
<AbsoluteFullFill w="full" h="full" justifyContent="center" alignItems="center">
Expand Down
16 changes: 1 addition & 15 deletions src/hooks/navigation/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
export { useBottomTabBarHeight } from '@react-navigation/bottom-tabs'
export {
useNavigationContainerRef,
useFocusEffect,
useIsFocused,
useLinkBuilder,
useLinkProps,
useLinkTo,
useNavigation,
useNavigationBuilder,
useNavigationState,
useRoute,
useScrollToTop,
} from '@react-navigation/native'
export { useCardAnimation, useGestureHandlerRef } from '@react-navigation/stack'
export * from './useNavigationStatePersistence'
export * from './useNavigationTheme'
export * from './usePreventGoBack'
export * from './useScreenOptions'
export * from './useScreenTracker'
export * from './useWeb'
export * from './useRouterNotifications'
39 changes: 39 additions & 0 deletions src/hooks/navigation/useRouterNotifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as Notifications from 'expo-notifications'
import { useRouter } from 'expo-router'
import React from 'react'

export function useRouterNotifications() {
const router = useRouter()

React.useEffect(() => {
let isMounted = true

function processUrl(url: string) {
// In case you need to modify the URL to make it relative.
return url
}

// Handle URL from expo push notifications
Notifications.getLastNotificationResponseAsync().then((response) => {
if (!isMounted) {
return
}
const url = response?.notification.request.content.data.url
if (url) {
router.replace(processUrl(url))
}
})

// Listen to expo push notifications
const subscription = Notifications.addNotificationResponseReceivedListener((response) => {
const url = response.notification.request.content.data.url
router.replace(processUrl(url))
})

return () => {
isMounted = false
subscription.remove()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
}
80 changes: 0 additions & 80 deletions src/hooks/useNotificationSetup.ts

This file was deleted.

55 changes: 0 additions & 55 deletions src/navigation/BottomTabNavigator.tsx

This file was deleted.

81 changes: 0 additions & 81 deletions src/navigation/RootNavigator.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions src/navigation/config/enums.ts

This file was deleted.

Loading