-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (43 loc) · 1.41 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
import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import MainNav from './src/navigation';
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/lib/integration/react';
import {store, persister} from './src/redux/store';
import {SafeAreaView, Platform} from 'react-native';
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/messaging';
import PushNotification from 'react-native-push-notification';
import PushNotificationIOS from '@react-native-community/push-notification-ios';
const App = () => {
useEffect(() => {
firebase.messaging().onMessage(response => {
if (Platform.OS !== 'ios') {
showNotification(response.notification);
return;
}
PushNotificationIOS.requestPermissions().then(() =>
showNotification(response.notification),
);
});
}, []);
const showNotification = notification => {
PushNotification.localNotification({
channelId: 'fcm_fallback_notification_channel',
title: notification.title,
message: notification.body,
});
};
return (
<Provider store={store}>
<PersistGate persistor={persister}>
<NavigationContainer>
<SafeAreaView style={{flex: 1}}>
<MainNav />
</SafeAreaView>
</NavigationContainer>
</PersistGate>
</Provider>
);
};
export default App;