-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
104 lines (98 loc) · 2.44 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
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
import { useEffect, useState } from 'react';
import { StatusBar, Text, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import Toast, {
BaseToast,
BaseToastProps,
ErrorToast,
} from 'react-native-toast-message';
import messaging from '@react-native-firebase/messaging';
import { NavigationContainer } from '@react-navigation/native';
import { QueryClientProvider } from '@tanstack/react-query';
import { colors } from '@/constants';
import useThemeStorage from '@/hooks/useThemeStorage';
import queryClient from './src/api/queryClient';
import RootNavigator from './src/navigations/root/RootNavigator';
/*
1. Create the config
*/
const toastConfig = {
/*
Overwrite 'success' type,
by modifying the existing `BaseToast` component
*/
success: (props: BaseToastProps) => (
<BaseToast
{...props}
style={{ borderLeftColor: 'pink' }}
contentContainerStyle={{ paddingHorizontal: 15 }}
text1Style={{
fontSize: 15,
fontWeight: '400',
}}
/>
),
/*
Overwrite 'error' type,
by modifying the existing `ErrorToast` component
*/
error: (props: BaseToastProps) => (
<ErrorToast
{...props}
text1Style={{
fontSize: 17,
}}
text2Style={{
fontSize: 15,
}}
/>
),
};
const linking = {
prefixes: ['meltingpot://'],
config: {
screens: {
FeedTab: 'FeedTab',
Alert: 'Alert',
ChatStart: 'ChatStart',
CommunityQuestionDetail: 'CommunityQuestionDetail',
CommunityPostingDetail: 'CommunityPostingDetail',
PartyDetail: 'PartyDetail',
UserProfile: 'UserProfile',
},
},
};
function App() {
const { theme } = useThemeStorage();
const [token, setToken] = useState('');
console.log(token, 'token');
const getFcmToken = async () => {
try {
const fcmToken = await messaging().getToken();
// console.log('[FCM Token] ', fcmToken);
} catch (e) {
console.log(e);
}
};
useEffect(() => {
getFcmToken();
const unsubscribe = messaging().onMessage(async remoteMessage => {
console.log('[Remote Message] ', JSON.stringify(remoteMessage));
});
return unsubscribe;
}, []);
return (
<QueryClientProvider client={queryClient}>
<StatusBar
barStyle={theme === 'light' ? 'dark-content' : 'light-content'}
/>
<GestureHandlerRootView>
<NavigationContainer linking={linking}>
<RootNavigator />
<Toast config={toastConfig} />
</NavigationContainer>
</GestureHandlerRootView>
</QueryClientProvider>
);
}
export default App;