-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
59 lines (52 loc) · 1.38 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, {useEffect} from 'react';
import {Button, Text, View} from 'react-native';
import usePushNotification from './usePushNotifications';
function App(): JSX.Element {
const {
requestUserPermission,
getFCMToken,
listenToBackgroundNotifications,
listenToForegroundNotifications,
onNotificationOpenedAppFromBackground,
onNotificationOpenedAppFromQuit,
scheduleNotification,
} = usePushNotification();
useEffect(() => {
const listenToNotifications = () => {
try {
getFCMToken();
requestUserPermission();
onNotificationOpenedAppFromQuit();
listenToBackgroundNotifications();
listenToForegroundNotifications();
onNotificationOpenedAppFromBackground();
} catch (error) {
console.log(error);
}
};
listenToNotifications();
}, []);
return (
<View
style={{justifyContent: 'center', alignItems: 'center', height: '100%'}}>
<Text style={{fontWeight: 'bold'}}>Test Notification App</Text>
<Button
title="Programar notification"
onPress={() =>
scheduleNotification(
'2023-09-05T20:22:00.000Z',
'Nueva notificación',
'¿Vamos a jugar?',
)
}
/>
</View>
);
}
export default App;