-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (49 loc) · 1.41 KB
/
index.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
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
import PushNotification, {Importance} from 'react-native-push-notification';
import messaging from '@react-native-firebase/messaging';
PushNotification.configure({
onRegister: function (token) {
// console.log('onRegister:', token);
},
onNotification: function (notification) {
console.log('onNotification:', notification);
notification.finish();
},
onAction: function (notification) {
console.log('ACTION:', notification.action);
console.log('NOTIFICATION:', notification);
},
onRegistrationError: function (err) {
console.error(err.message, err);
},
permissions: {
alert: true,
badge: true,
sound: true,
},
popInitialNotification: true,
requestPermissions: true,
});
PushNotification.createChannel({
channelId: 'user-channel',
channelName: 'User Channel',
channelDescription: 'A channel for user',
soundName: 'default',
importance: Importance.HIGH,
vibrate: true,
});
// Check if app was launched in the background and conditionally render null if so
function HeadlessCheck({isHeadless}) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null;
}
// Render the app component on foreground launch
return <App />;
}
AppRegistry.registerComponent(appName, () => HeadlessCheck);