-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
62 lines (55 loc) · 1.7 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
56
57
58
59
60
61
62
import React, { useEffect } from "react";
import { StyleSheet } from "react-native";
import { fcmService } from "./src/FCMService";
import { localNotificationService } from "./src/LocalNotificationService";
import AppContainer from "./navigation/AppContainer";
import SplashScreen from "react-native-splash-screen";
import StatusBarBackground from './src/iosStatusBarWrapper';
export default function App() {
useEffect(() => {
SplashScreen.hide();
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, //,
// largeIcon: 'ic_launcher', // add icon large for Android (Link: app/src/main/mipmap)
// smallIcon: 'ic_launcher' // add icon small for Android (Link: app/src/main/mipmap)
};
localNotificationService.showNotification(
0,
notify.title,
notify.body,
notify,
options
);
}
function onOpenNotification(notify) {
console.log("[App] onOpenNotification: ", notify);
}
return () => {
console.log("[App] unRegister");
fcmService.unRegister();
localNotificationService.unregister();
};
}, []);
return (
<React.Fragment>
<StatusBarBackground/>
<AppContainer />
</React.Fragment>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
});