-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
108 lines (93 loc) · 2.72 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import Navigator from './src/Navigation/navigation'
import { Provider } from 'react-redux';
import store from './src/Redux/Store/store'
import NavigtionService from './src/Navigation/NavigationService';
import messaging from '@react-native-firebase/messaging';
import FlashMessage from "react-native-flash-message";
import { LocalizationProvider } from './src/Localization/LocalizationContext';
import { Root, Spinner } from 'native-base';
import AsyncStorage from '@react-native-community/async-storage';
export default class App extends React.Component {
constructor (props) {
super(props);
this.state = {
profileData: '',
loading: true,
}
}
componentDidMount () {
// AsyncStorage.clear()
console.log(" this.props.navigation.state Notification APP.JS")
messaging()
.getInitialNotification()
.then(remoteMessage => {
if(remoteMessage) {
console.log(
'Notification caused app to open from quit state: this.props.navigation.state ',
remoteMessage,
);
NavigtionService.navigate("Splash", {notification: true})
}
});
messaging().onNotificationOpenedApp(remoteMessage => {
if(remoteMessage) {
console.log(
' Notification caused app to open from background state:',
remoteMessage.notification,
);
NavigtionService.navigate("Splash", {notification: true})
}
});
// Check whether an initial notification is available
// setTimeout(() => {
this.setState({ loading: false });
// }, 9000)
}
fetchProfileData = (data) => {
this.setState({
profileData: data
})
}
render() {
console.disableYellowBox = true
if (this.state.loading) {
return <Spinner />
}
return (
<View style={{ flex:1 }}>
<Provider store={store}>
<LocalizationProvider>
<Root>
{this.state.loading ?
<Spinner />
:
<Navigator
screenProps={{ fetchProfileData: this.fetchProfileData, profileData: this.state.profileData }}
ref={(navigatorRef) => {
NavigtionService.setTopLevelNavigator(navigatorRef);
}} />
}
</Root>
</LocalizationProvider>
</Provider>
<FlashMessage position="top" style={{marginTop: 10, backgroundColor:'#3A91FA'}} />
</View>
);
}
};