我正在使用React Native製作的應用程序中的註冊表屏幕上工作。我正在使用Firebase身份驗證來創建新用戶。React Native + Firebase身份驗證 - displayName
在登錄屏幕上,我使用.signInWithEmailAndPassword(訪問帳戶),並在註冊屏幕上使用.createUserWithEmailAndPassword(創建用戶)以及閱讀有關Firebase身份驗證的文章,我知道我可以使用displayName接收用戶名,用photoUrl接收用戶的照片。
我想要做的是使用用戶名,電子郵件和密碼創建一個新用戶。即使閱讀關於這個問題的文章,我也不知道這樣做的方法。
這是我的代碼:
signup() {
this.setState({
// When waiting for the firebase server show the loading indicator.
loading: true
});
// Make a call to firebase to create a new user.
this.props.firebaseApp.auth().createUserWithEmailAndPassword(this.state.email, this.state.password).then((userData) => {
// then and catch are methods that we call on the Promise returned from
// createUserWithEmailAndPassword
Alert.alert('Success', 'Congrats!', [{text: 'OK!', onPress: this.dismiss}]);
this.setState({
// Clear out the fields when the user logs in and hide the progress indicator.
email: '',
password: '',
loading: false
});
AsyncStorage.setItem('userData', JSON.stringify(userData));
this.props.navigator.push({
component: Account
});
}).catch((error) => {
// Leave the fields filled when an error occurs and hide the progress indicator.
this.setState({
loading: false
});
Alert.alert('Ops', 'Error: ' + error.message, [{text: 'OK!', onPress: this.dismiss}]);
});
}
基本上我想創建一個使用火力地堡認證的用戶名,電子郵件地址和密碼的新用戶。
你們中的任何人都可以給我舉一個例子,說明如何使用用戶名,電子郵件和密碼創建用戶?
如果你想看看我正在嘗試做什麼,我創建了一個項目來提高我對React Native的瞭解? https://github.com/JoaoVRodrigues01/React-Native-Codec-App
嘿,謝謝你的回答!在登錄屏幕中,用戶將使用電子郵件和密碼進入帳戶,並且在註冊屏幕中,用戶將使用姓名,電子郵件和密碼創建一個帳戶。我想在註冊表中詢問用戶名以在屏幕上返回用戶信息,將會顯示用戶帳戶信息,例如用戶名和電子郵件。 –
我很抱歉,但我不明白你的用例。 – bojeil
基本上我想用用戶名,電子郵件和密碼使用Firebase身份驗證創建一個用戶。但沒問題。不管怎樣,謝謝你! –