-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (40 loc) · 1.47 KB
/
index.js
File metadata and controls
47 lines (40 loc) · 1.47 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
import React from 'react';
import { AppRegistry, Text, TextInput } from 'react-native';
import { name as appName } from './app.json';
import Main from './src/Main';
import { onMessageInBackground } from '/utils/notification';
import messaging from '@react-native-firebase/messaging';
import notifee, { EventType } from '@notifee/react-native';
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.autoCorrect = false;
TextInput.defaultProps.allowFontScaling = false;
navigator.geolocation = require('react-native-geolocation-service');
messaging().setBackgroundMessageHandler(onMessageInBackground);
notifee.onBackgroundEvent(async ({ type, detail }) => {
const { notification, pressAction } = detail;
if (
notification === undefined ||
pressAction === undefined ||
type === undefined ||
notification.id === undefined
) {
return;
}
// Check if the user pressed the "Mark as read" action
if (type === EventType.ACTION_PRESS && pressAction.id === 'mark-as-read') {
// Decrement the count by 1
await notifee.decrementBadgeCount();
// Remove the notification
await notifee.cancelNotification(notification.id);
}
});
function HeadlessCheck({ isHeadless }) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null;
}
return <Main />;
}
AppRegistry.registerComponent(appName, () => HeadlessCheck);