Я пытаюсь интегрировать вход в Facebook с реагировать на родной и firebase.
Пуск кажется работающим, но затем я получаю пустой экран ...
Так чего не хватает в моей логике c, пожалуйста?
export default class App extends React.Component {
constructor(props) {
super(props);
//check if logged in
f.auth().onAuthStateChanged(function (user) {
if (user) {
//logged in
console.log('*** logged in', user);
} else {
//logged out
console.log('*** logged out');
}
});
}
async loginWithFacebook() {
await Facebook.initializeAsync('2345');
const {
type,
token
} = await Facebook.logInWithReadPermissionsAsync({
permissions: ['email', 'public_profile'],
});
if (type === 'success') {
const credentials = f.auth.FacebookAuthProvider.credential(token);
f.auth().signInWithCredential(credentials).catch((error) => {
console.log(`Facebook Login Error: ${error}`);
})
}
}
registerUser = (email, password) => {
console.log(email, password);
auth.createUserWithEmailAndPassword(email, password)
.then((userObj) => console.log(email, password, userObj))
.catch((error) => console.log('errore:', error));
}
render() {
return (
<View style={styles.container}>
<Text>MaKo Open up App.js to start working on your app!</Text>
<TouchableHighlight
onPress={() => this.loginWithFacebook()}
style={{ backgroundColor: 'green' }}>
<Text style={{ color: 'white' }}>Login with FB</Text>
</TouchableHighlight>
</View>
);
}
}