-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
60 lines (56 loc) · 1.8 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
import React, {useEffect, useState} from 'react';
import MainNav from './src/Navigations/mainNav';
import {Provider, useDispatch, useSelector} from 'react-redux';
import {PersistGate} from 'redux-persist/lib/integration/react';
import {store, persister} from './src/redux/store';
import {SafeAreaView} from 'react-native';
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/messaging';
import PushNotification from 'react-native-push-notification';
import messaging from '@react-native-firebase/messaging';
const App = () => {
useEffect(() => {
console.log('flanra()');
flanra();
}, []);
const flanra = async () => {
console.log('===>.......................');
const token = await messaging().getToken();
console.log('ttokenn.......................');
console.log(token);
};
useEffect(() => {
firebase.messaging().onMessage(response => {
console.log(JSON.stringify(response));
console.log(JSON.stringify(response));
showNotification(response.notification);
});
PushNotification.configure({
// Other configuration options
onNotificationOpened: notification => {
// Handle the notification
console.log('OPENED:.......', notification);
},
});
// firebase.notifications().onNotificationOpened(response => {
// // do something
// });
}, []);
const showNotification = notification => {
PushNotification.localNotification({
channelId: 'fcm_fallback_notification_channel',
title: notification.title,
message: notification.body,
});
};
return (
<Provider store={store}>
<SafeAreaView style={{flex: 1}}>
<PersistGate persistor={persister}>
<MainNav />
</PersistGate>
</SafeAreaView>
</Provider>
);
};
export default App;