-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
61 lines (54 loc) · 1.6 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
import React from 'react';
import { createAppContainer } from 'react-navigation';
import { View, Text, StyleSheet } from 'react-native';
import firebase from 'firebase';
import { Spinner } from './src/components/common';
import AppNavigator from './src/navigation/AppNavigator';
import User from './src/db/User';
const AppContainer = createAppContainer(AppNavigator);
export default class App extends React.Component {
state = {
isLoggedIn: false,
};
async componentWillMount() {
console.log(process.env.FIREBASE_API_KEY);
var fbConfig = {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: 'react-native-local-storage.firebaseapp.com',
databaseURL: 'https://react-native-local-storage.firebaseio.com',
projectId: 'react-native-local-storage',
storageBucket: 'react-native-local-storage.appspot.com',
messagingSenderId: '654684231418',
};
firebase.initializeApp(fbConfig);
console.log("checking if user is authed")
firebase.auth().onAuthStateChanged(async user => {
if (user) {
console.log('user is loggeded in');
} else {
const user = await User.loginAnonymous();
}
this.setState({ loggedIn: true });
});
//const user = await User.loginAnonymous();
//this.setState({ loggedIn: true });
}
render() {
if (this.state.loggedIn) {
return <AppContainer />;
} else {
return (
<View style={styles.container}>
<Spinner />
</View>
);
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
paddingTop: 20,
},
});