import { Navigation } from './src/navigation/navigation'; import { Provider } from 'react-redux'; import { store } from './src/store'; import React, { useState, useRef } from 'react'; import * as Notifications from 'expo-notifications'; import { registerForPushNotificationsAsync, } from './src/notifications/useNotification'; import { ThemeProvider } from 'styled-components'; import { theme } from './src/theme/theme'; Notifications.setNotificationHandler({ handleNotification: async () => ({ shouldShowAlert: true, shouldPlaySound: false, shouldSetBadge: false, }), }); export default function App () { const [expoPushToken, setExpoPushToken] = useState(''); const [notification, setNotification] = useState(false); const notificationListener = useRef(); const responseListener = useRef(); React.useEffect(() => { registerForPushNotificationsAsync().then(token => setExpoPushToken(token)); notificationListener.current = Notifications.addNotificationReceivedListener( notification => { setNotification(notification); console.log(notification); }); responseListener.current = Notifications.addNotificationResponseReceivedListener( response => { console.log('response'); }); return () => { Notifications.removeNotificationSubscription( notificationListener.current); Notifications.removeNotificationSubscription(responseListener.current); }; }, []); return ( <ThemeProvider theme={theme}> <Provider store={store}> <Navigation/> </Provider> </ThemeProvider> ); }