-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
executable file
·43 lines (37 loc) · 1.02 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
import React, {useEffect} from 'react';
import Notifications from './notifications';
import {SafeAreaView, StyleSheet, View, Button} from 'react-native';
export const App = () => {
useEffect(() => {
Notifications.configure();
}, []);
Notifications.wasOpenedByNotification();
const sendLocalNotification = delay_seconds => {
const date = new Date();
date.setSeconds(date.getSeconds() + delay_seconds);
Notifications.scheduleNotification(date);
};
return (
<SafeAreaView style={{flex: 1}}>
<View style={styles.container}>
<Button
onPress={() => sendLocalNotification(1)}
title="Scheduled notification for now"
/>
<Button
onPress={() => sendLocalNotification(10)}
title="Scheduled notification for 10 seconds from now"
/>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'space-around',
padding: 8,
},
});
export default App;