-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
124 lines (111 loc) Β· 3.24 KB
/
App.tsx
File metadata and controls
124 lines (111 loc) Β· 3.24 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import React, { useEffect } from 'react';
import BootSplash from 'react-native-bootsplash';
import Toast, { BaseToast, BaseToastProps, ErrorToast } from 'react-native-toast-message';
import notifee, { AndroidImportance } from '@notifee/react-native';
import { FirebaseMessagingTypes, getMessaging, onMessage } from '@react-native-firebase/messaging';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { QueryClientProvider } from '@tanstack/react-query';
import queryClient from '@/api/queryClient';
import { colors } from '@/constants/colors';
import useAuth from '@/hooks/queries/useAuth';
import { NotificationProvider } from '@/hooks/useNotification';
import RootNavigator from '@/navigations/root/RootNavigator';
import pushNoti from '@/utils/pushNoti';
const AppTheme = {
...DefaultTheme,
};
const toastConfig = {
success: (props: BaseToastProps) => (
<BaseToast
{...props}
style={{ borderLeftColor: 'transparent', backgroundColor: colors.BLACK }}
text1Style={{
fontSize: 14,
fontFamily: 'Pretendard-Medium',
fontWeight: 'normal',
color: colors.WHITE,
}}
text2Style={{
fontSize: 12,
fontFamily: 'Pretendard-Regular',
fontWeight: 'normal',
color: colors.WHITE,
}}
/>
),
error: (props: BaseToastProps) => (
<ErrorToast
{...props}
style={{ borderLeftColor: 'transparent', backgroundColor: colors.BLACK }}
text1Style={{
fontSize: 14,
fontFamily: 'Pretendard-SemiBold',
fontWeight: 'normal',
color: colors.WHITE,
}}
text2Style={{
fontSize: 12,
fontFamily: 'Pretendard-Regular',
fontWeight: 'normal',
color: colors.WHITE,
}}
/>
),
};
function AppContentInner() {
const { isLoading } = useAuth();
useEffect(() => {
if (!isLoading) {
BootSplash.hide({ fade: true });
}
}, [isLoading]);
useEffect(() => {
async function setupNotificationChannel() {
try {
const channel = await notifee.createChannel({
id: 'default',
name: 'RE:FOOD',
importance: AndroidImportance.HIGH,
});
console.log('Notification channel created:', channel);
const channels = await notifee.getChannels();
console.log('Available channels:', channels);
} catch (error) {
console.error('Error creating notification channel:', error);
}
}
setupNotificationChannel();
}, []);
useEffect(() => {
const messagingInstance = getMessaging();
const unsubscribe = onMessage(
messagingInstance,
async (remoteMessage: FirebaseMessagingTypes.RemoteMessage) => {
console.log('FCM message received:', remoteMessage);
pushNoti.displayNoti(remoteMessage);
}
);
return unsubscribe;
}, []);
return (
<NavigationContainer theme={AppTheme}>
<RootNavigator />
<Toast config={toastConfig} />
</NavigationContainer>
);
}
function AppContent() {
return (
<QueryClientProvider client={queryClient}>
<AppContentInner />
</QueryClientProvider>
);
}
function App() {
return (
<NotificationProvider>
<AppContent />
</NotificationProvider>
);
}
export default App;