-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (38 loc) · 1.17 KB
/
index.js
File metadata and controls
46 lines (38 loc) · 1.17 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
/**
* @format
*/
import {AppRegistry, Text, TextInput} from 'react-native';
import messaging from '@react-native-firebase/messaging';
import notifee, {EventType} from '@notifee/react-native';
import App from './src';
import {name as appName} from './app.json';
if (__DEV__) {
import('./ReactotronConfig').then(() => console.log('Reactotron Configured'));
}
if (Text.defaultProps == null) {
Text.defaultProps = {};
}
Text.defaultProps.allowFontScaling = false;
if (TextInput.defaultProps == null) {
TextInput.defaultProps = {};
}
TextInput.defaultProps.allowFontScaling = false;
messaging().setBackgroundMessageHandler(async remoteMessage => {
await notifee.displayNotification({
title: remoteMessage.notification.title,
body: remoteMessage.notification.body,
android: {
channelId: 'default',
},
});
notifee.incrementBadgeCount(1);
});
// Background Event Listener
notifee.onBackgroundEvent(async ({type, detail}) => {
const {notification, pressAction} = detail;
if (type === EventType.ACTION_PRESS) {
await notifee.cancelNotification(notification.id);
notifee.decrementBadgeCount(1);
}
});
AppRegistry.registerComponent(appName, () => App);