-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
103 lines (82 loc) · 2.72 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import React, {Component} from 'react';
import {StatusBar} from 'react-native';
import FlashMessage from 'react-native-flash-message';
import messaging from '@react-native-firebase/messaging';
import AppContainer from './scenes/AppContainer';
import NavigationService from './services/navigationservice.js';
import * as Constants from './util/constants';
class App extends Component {
async componentDidMount() {
try {
await messaging().requestPermission();
messaging().subscribeToTopic(
Constants.notificationTopics.topTenCountdown
);
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log(remoteMessage);
});
} catch (error) {
console.error(error);
}
// try {
// await notifee.requestPermission();
// await notifee.createChannel({
// id: Constants.notificationTopics.nowPlaying,
// name: 'Now Playing',
// });
// await notifee.createChannel({
// id: Constants.notificationTopics.requests,
// name: 'Requests',
// });
// await notifee.createChannel({
// id: Constants.notificationTopics.topTenCountdown,
// name: 'Top Ten Countdown',
// });
// messaging().onMessage(this.onMessageReceived);
// messaging().setBackgroundMessageHandler(this.onMessageReceived);
// } catch (error) {
// console.error(error);
// }
}
// async onMessageReceived(message) {
// let shouldShowNotification = true;
// const messageData = JSON.parse(message.data.notifee);
// if (messageData.topic === Constants.notificationTopics.requests) {
// const username = await UserService.getUsername();
// shouldShowNotification =
// username && messageData.data && messageData.data.username === username;
// }
// if (shouldShowNotification) {
// messageData.android = {
// channelId: messageData.topic,
// smallIcon: 'ic_stat_appbar_icon',
// style: {
// type: AndroidStyle.BIGTEXT,
// text: messageData.body,
// },
// };
// if (messageData.imageUrl) {
// messageData.android.largeIcon = messageData.imageUrl;
// }
// messageData.notification = {
// body: messageData.body,
// title: messageData.title,
// };
// await notifee.displayNotification(messageData);
// }
// }
render() {
return (
<>
<StatusBar backgroundColor="#000000" barStyle="light-content" />
<AppContainer
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
<FlashMessage floating={true} position="bottom" />
</>
);
}
}
export default App;