forked from rodrigo2392/lizt-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
88 lines (81 loc) · 2.72 KB
/
App.tsx
File metadata and controls
88 lines (81 loc) · 2.72 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
import React, {useEffect} from 'react';
import {Provider} from 'react-redux';
import SplashScreen from 'react-native-splash-screen';
import {WalkthroughProvider} from 'react-native-interactive-walkthrough';
import {PersistGate} from 'redux-persist/integration/react';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {enableExperimentalLayoutAnimation} from 'react-native-interactive-walkthrough';
import dayjs from 'dayjs';
import Navigation from './src/navigation';
import {persistStore} from 'redux-persist';
import store from './src/redux/store';
import notifee, {EventType} from '@notifee/react-native';
import './src/localization';
import useCheckPermission from './src/hook/useCheckPermission';
import {useNotification} from './src/hook/useNotification';
import {EmojiProvider} from '@rodrigo2392/react-native-emoji-modal';
import {createNavigationContainerRef} from '@react-navigation/native';
import {HomeStackParamList} from './src/navigation/App';
dayjs.locale('es-mx');
let persistor = persistStore(store);
enableExperimentalLayoutAnimation();
export const navigationRef = createNavigationContainerRef<HomeStackParamList>();
function App(): React.JSX.Element {
useCheckPermission();
useNotification();
useEffect(() => {
SplashScreen.hide();
}, []);
notifee.onBackgroundEvent(async ({type, detail}) => {
if (type === EventType.DISMISSED) {
// Update remote API
}
if (type === EventType.PRESS) {
if (navigationRef.isReady()) {
navigationRef.navigate('Reminders', {
isTab: true,
});
setTimeout(() => {
return navigationRef.navigate('Reminders', {
isTab: true,
itemId: detail?.notification?.data?.reminderId?.toString() ?? '',
});
}, 500);
}
}
notifee.setBadgeCount(0);
});
notifee.onForegroundEvent(async ({type, detail}) => {
if (type === EventType.DISMISSED) {
// Update remote API
}
if (type === EventType.PRESS) {
if (navigationRef.isReady()) {
navigationRef.navigate('RemindersStack', {
isTab: true,
});
setTimeout(() => {
navigationRef.navigate('Reminders', {
isTab: true,
itemId: detail?.notification?.data?.reminderId?.toString() ?? '',
});
}, 500);
}
}
notifee.setBadgeCount(0);
});
return (
<GestureHandlerRootView>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<EmojiProvider>
<WalkthroughProvider>
<Navigation />
</WalkthroughProvider>
</EmojiProvider>
</PersistGate>
</Provider>
</GestureHandlerRootView>
);
}
export default App;