-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
45 lines (38 loc) · 1.57 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
import SplashScreen from 'react-native-splash-screen';
import messaging from '@react-native-firebase/messaging';
import notifee from '@notifee/react-native';
import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {RootStack} from 'navigation/RootStack';
import {Provider} from 'react-redux';
import {persistor, store} from 'reduxStore/store';
import {setupAuthInterceptors} from 'features/auth/setupAuthInterceptors';
import {ToastOutline} from 'core/utils/toast';
import {useRequestPushPermissions} from 'features/push/hooks/useRequestPushPermissions';
import {useForegroundPushNotifications} from 'features/push/hooks/useForegroundPushNotifications';
import {PersistGate} from 'redux-persist/integration/react';
// Create the notification channel for Android devices.
// Don't forget to change the messaging_android_notification_channel_id in the firebase.json.
notifee.createChannel({id: 'default', name: 'Default', sound: 'default'});
setupAuthInterceptors(store);
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('Background push notification arrived', remoteMessage);
});
const App = (): JSX.Element => {
useRequestPushPermissions();
useForegroundPushNotifications();
useEffect(() => SplashScreen.hide(), []);
return (
<>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<NavigationContainer>
<RootStack />
</NavigationContainer>
</PersistGate>
</Provider>
<ToastOutline />
</>
);
};
export default App;