-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
61 lines (51 loc) · 1.77 KB
/
App.tsx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { useRef, useEffect } from 'react'
import { StatusBar } from 'react-native'
import {
useFonts,
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
} from '@expo-google-fonts/inter'
import { Subscription } from 'expo-modules-core';
import * as Notifications from 'expo-notifications';
import { Loading } from './src/components/Loading';
import { Background } from './src/components/Background';
import { Routes } from './src/routes';
import './src/services/notificationConfigs';
import { getPushNotificationToken } from './src/services/getPushNotificationToken';
export default function App() {
const [fontsLoaded] = useFonts({
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
});
const getNotificationListener = useRef<Subscription>();
const responseNotificationListener = useRef<Subscription>();
useEffect(() => {
// Push Notification Tool can be implemented here.
getPushNotificationToken();
})
useEffect(() => {
getNotificationListener.current = Notifications
.addNotificationReceivedListener(notification => {
console.log(notification);
});
responseNotificationListener.current = Notifications.addNotificationResponseReceivedListener(response => {
console.log(response)
})
return () => {
if (getNotificationListener.current && responseNotificationListener.current) {
Notifications.removeNotificationSubscription(getNotificationListener.current);
Notifications.removeNotificationSubscription(responseNotificationListener.current);
}
}
}, [])
return (
<Background>
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent/>
{ fontsLoaded ? <Routes /> : <Loading />}
</Background>
);
}