我正在尝试将电话号码验证添加到我的应用程序中。我收到的错误告诉我,signInWithPhoneNumber()方法需要两个参数,但是我只有一个。我知道我需要添加RecaptchaVerifier,但不确定如何添加。
我尝试查看Firebase文档,但至少从我的理解来看,它们并不清楚。
// @flow
import autobind from "autobind-decorator";
import * as React from "react";
import {StyleSheet, View} from "react-native";
import {TextField, Switch, Theme, Text, Firebase} from "../components";
import type {NavigationProps} from "../components/Types";
import * as firebase from "firebase";
import SignUpNumberContainer from "./SignUpNumberContainer";
type NumberState = {
number: string
};
export default class NumberVerify extends React.Component<NavigationProps<*>, NumberState> {
componentWillMount() {
this.setState({ number: ""});
}
@autobind
setNumber(number: string) {
this.setState ({ number });
}
@autobind
async next() {
const {number} = this.state;
firebase.auth().signInWithPhoneNumber(number)
.then((confirmResult) => {
this.setState({ confirmResult });
})
.catch((error) => {
const { code, message } = error;
});
}
// @autobind
// next() {
// const { number } = this.state;
// Firebase.registrationInfo.number = number;
// this.props.navigation.navigate("SignUpPassword");
// }
render(): React.Node {
const {navigation} = this.props;
return (
<SignUpNumberContainer title="Your Number" subtitle="Used for verification" next={this.next} {...{ navigation }}>
<TextField
placeholder="Number"
keyboardType="numeric"
autoCapitalize="none"
autoCorrect={false}
returnKeyType="go"
onSubmitEditing={this.next}
onChangeText={this.setNumber}
contrast
/>
<View style={styles.row}>
<Text style={styles.text}>
Standard SMS and Data rates may apply.
</Text>
</View>
</SignUpNumberContainer>
);
}
}