-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
61 lines (52 loc) · 1.71 KB
/
Copy pathApp.js
File metadata and controls
61 lines (52 loc) · 1.71 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
import React, {useEffect} from 'react';
import {RootSiblingParent} from 'react-native-root-siblings';
import {fcmService} from './src/Notification/FCMService';
import {localNotificationService} from './src/Notification/LocalNotificationoService';
import Paper from './src/theme/Paper';
import {StateProvider} from './src/contextStore/StateProvider';
import contextReducer, {initialState} from './src/contextStore/contextReducer';
import {alert} from './src/util/alert';
export default function App() {
useEffect(() => {
fcmService.registerAppWithFCM();
fcmService.register(onRegister, onNotification, onOpenNotification);
localNotificationService.configure(onOpenNotification);
function onRegister(token) {
console.log('[App] onRegister: ', token);
}
function onNotification(notify) {
console.log('[App] onNotification: ', notify);
const options = {
soundName: 'default',
playSound: true,
};
localNotificationService.showNotification(
0,
notify.title,
notify.body,
notify,
options
);
alert(notify.title, notify.body, true, [
{text: 'OK', onPress: () => console.log('OK Pressed')},
]);
}
function onOpenNotification(notify) {
console.log('[App] onOpenNotification: ', notify);
alert(notify.title, notify.body, true, [
{text: 'OK', onPress: () => console.log('OK Pressed')},
]);
}
return () => {
console.log('[App] unregister');
fcmService.unRegister();
};
}, []);
return (
<RootSiblingParent>
<StateProvider initialState={initialState} reducer={contextReducer}>
<Paper />
</StateProvider>
</RootSiblingParent>
);
}