Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
};
}, []);
<ThemeProvider theme={theme}>
<Provider store={store}>
<Navigation/>
</Provider>
</ThemeProvider>