-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
54 lines (47 loc) · 1.69 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
import { StatusBar } from "react-native";
import { Background } from "./src/components/Background";
import {
useFonts,
Inter_400Regular,
Inter_600SemiBold, Inter_700Bold, Inter_900Black
} from "@expo-google-fonts/inter";
import { Routes } from "./src/routes";
import { Loading } from "./src/components/Loading";
import "./src/services/notificationConfig";
import { getPushNotificationToken } from "./src/services/getPushNotificationToken";
import {useRef, useEffect} from "react";
import {Subscription} from "expo-modules-core";
import * as Notifications from "expo-notifications";
export default function App() {
const getNotificationListener = useRef<Subscription>();
const responseNotificationListener = useRef<Subscription>();
useEffect(() => {
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);
}
};
},[]);
const [fontsLoaded] = useFonts({
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
});
return (
<Background>
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent />
{fontsLoaded ? <Routes /> : <Loading />}
</Background>
);
}