使用 Firebase 在 React Native 中进行身份验证
使用 app api 值替换 firebase 值:
import firebase from 'firebase';
componentWillMount() {
firebase.initializeApp({
apiKey: "yourAPIKey",
authDomain: "authDomainNAme",
databaseURL: "yourDomainBaseURL",
projectId: "yourProjectID",
storageBucket: "storageBUcketValue",
messagingSenderId: "senderIdValue"
});
firebase.auth().signInWithEmailAndPassword(email, password)
.then(this.onLoginSuccess)
.catch(() => {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(this.onLoginSuccess)
.catch(this.onLoginFail)
})
}