-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
57 lines (46 loc) · 1.4 KB
/
App.js
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
import { useCallback, useEffect } from 'react';
import { View } from 'react-native';
import AlarmPage from './pages/AlarmPage.js';
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import notifee, { EventType } from '@notifee/react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
// SplashScreen.preventAutoHideAsync();
export default function App() {
useEffect(() => {
async function requestPermission() {
await notifee.requestPermission()
}
requestPermission()
}, []);
// Subscribe to events
useEffect(() => {
return notifee.onForegroundEvent(({ type, detail }) => {
switch (type) {
case EventType.DISMISSED:
console.log('User dismissed notification', detail.notification);
break;
case EventType.PRESS:
console.log('User pressed notification', detail.notification);
break;
}
});
}, []);
const [fontsLoaded] = useFonts({
'Jet-Bold': require('./assets/fonts/JetBrainsMono-Bold.ttf'),
'Jet-Regular': require('./assets/fonts/JetBrainsMono-Regular.ttf'),
});
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded]);
if (!fontsLoaded) {
return null;
}
return (
<GestureHandlerRootView>
<AlarmPage />
</GestureHandlerRootView>
);
}