cantaş
cantaş

Reputation: 136

how to connect expo app on my own phone to firebase?Is it possible?

I'm new to React native. Today I wanted to create a login and sign up page linked to firebase. I followed this tutorial -https://www.youtube.com/watch?v=TkuQAjnaSbM&t=110s - word for word and found it very successful.

I installed the expo application on my ios phone and I get the builds from there. The only difference between us and the tutorial in the video is that it uses an android emulator and I get build on the expo application on my real phone. But the problem is that I cannot add new users to the firebase via the script. I also share the code. I would appreciate if you help.

handleSignUp=() => {
    firebase
    .auth()
    .createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then(userCredentinals => {
            return userCredentinals.user.updateProfile({
                displayName: this.state.name
            });
    })
    .catch(error => this.setState({ errorMessage: error.messsage}));
};

somehow I can't connect with firebase. but I'm sure I put the config code block in the right place. Maybe I am not authorized to write my own phone to the database I use as an emulator?

<TouchableOpacity style={styles.button}> 
                        <Text style={{color:"#FFF", fontWeight: "500"}}
                        onPress={this.handleSignUp}
                        onPress={() => this.props.navigation.navigate("Home")}
                        >Kayıt Ol</Text>
                    </TouchableOpacity>

enter image description here

Upvotes: 2

Views: 342

Answers (1)

Sennen Randika
Sennen Randika

Reputation: 1646

Please update your function like this.

const handleSignUp = () => {
    console.log('Function is called');

    firebase
    .auth()
    .createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then(userCredentinals => {
            console.log('Success');
            return userCredentinals.user.updateProfile({
                displayName: this.state.name
            });
    })
    .catch(error => {
       console.log(error);
       this.setState({ errorMessage: error.messsage});
    });
};

Then please update your question with what you get displayed in the console. Then I will be able to help you to solve this problem.

Upvotes: 1

Related Questions