-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
59 lines (51 loc) · 1.71 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
import './src/services/notificationsConfig'
import * as Notifications from 'expo-notifications'
import { useEffect, useRef } from 'react'
import {
useFonts,
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
} from '@expo-google-fonts/inter'
import { StatusBar } from 'react-native'
import { Subscription } from 'expo-modules-core'
import { Background } from './src/components/Background'
import { Loading } from './src/components/Loading'
import { Routes } from './src/routes'
import { getPushNotificationToken } from './src/services/getPushNotificationToken'
export default function App() {
const getNotificationListener = useRef<Subscription>()
const responseNotificationListener = useRef<Subscription>()
const [fontsLoaded] = useFonts({
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
})
useEffect(() => {
getPushNotificationToken()
})
useEffect(() => {
getNotificationListener.current =
Notifications.addNotificationReceivedListener(notification => {console.log(notification)})
responseNotificationListener.current =
Notifications.addNotificationResponseReceivedListener(notification => {console.log(notification)})
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>
)
}