-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (43 loc) · 1.31 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
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import PushNotification from 'react-native-push-notification';
import AsyncStorage from '@react-native-async-storage/async-storage';
import messaging from '@react-native-firebase/messaging';
PushNotification.configure({
onRegister: async function (res) {
await AsyncStorage.setItem('token', res.token);
// console.log(res.token);
},
onNotification: function (notification) {
console.log('NOTIFICATION:', notification);
},
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: 'jara',
channelName: 'jara',
});
messaging().setBackgroundMessageHandler(async remoteMessage => {
PushNotification.localNotification({
channelId: 'jara',
channelName: 'jara',
title: remoteMessage.notification.title,
message: remoteMessage.notification.body,
timeoutAfter: 30000,
});
});
AppRegistry.registerComponent(appName, () => App);