-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
62 lines (55 loc) · 1.96 KB
/
App.tsx
File metadata and controls
62 lines (55 loc) · 1.96 KB
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
62
import { NavigationContainer } from "@react-navigation/native";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useFonts } from "expo-font";
import * as Notifications from "expo-notifications";
import * as React from "react";
import { useEffect, useRef } from "react";
import { AuthConsumer } from "./src/components/auth/AuthConsumer";
import { AuthProvider } from "./src/context/AuthContext";
export default function App() {
const queryClient = new QueryClient();
const navigationRef = useRef<any>(null);
//폰트 시스템
const [fontsLoaded] = useFonts({
SCDream6: require("./src/assets/fonts/SCDream6.otf"),
SCDream5: require("./src/assets/fonts/SCDream5.otf"),
SCDream4: require("./src/assets/fonts/SCDream4.otf"),
Oblique: require("./src/assets/fonts/Oblique.otf"),
});
useEffect(() => {
// 푸시 알림 핸들링 설정
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
shouldShowBanner: true,
shouldShowList: true,
}),
});
// 푸시 알림 클릭 리스너
const subscription = Notifications.addNotificationResponseReceivedListener(
(response) => {
const data = response.notification.request.content.data;
if (data && data.alarmType && navigationRef.current) {
if (data.alarmType === "FRIEND") {
navigationRef.current.navigate("FriendPage");
} else if (data.alarmTypce === "CHALLENGE") {
navigationRef.current.navigate("Challenge");
}
}
}
);
return () => subscription.remove();
}, []);
if (!fontsLoaded) return null;
return (
<QueryClientProvider client={queryClient}>
<AuthProvider>
<NavigationContainer ref={navigationRef}>
<AuthConsumer />
</NavigationContainer>
</AuthProvider>
</QueryClientProvider>
);
}