我已经使用Firebase电话身份验证在Flutter应用中实现了电话号码身份验证。在Android中运行正常。但这在iOS中无法正常运行,因为许多用户在提交短信验证码后都遇到了错误,尽管很多其他人都很好地使用了该应用。这种情况可能是什么原因?我已经在下面提交了我的代码。
提交号码
let rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
if (flags.interactive || args.cmd === 'bash') {
execService.exec(this, id, appUrl, { Detach: false, Tty: flags.tty }).then(response => {
let stream = response.data;
let socket = stream.socket;
socket.on('data', (data: string) => {
process.stdin.pause();
if (!firstLine) {
process.stdout.write(data);
}
firstLine = false;
process.stdin.resume()
})
process.stdin.on('data', i => {
socket.write(i.toString())
if (i == DetachKey) {
rl.emit('SIGINT')
}
})
rl.on('SIGINT', function () {
// stop input
socket.emit('end')
process.stdin.pause()
process.stdout.write(exec_exit_msg)
process.exit(0)
})
});
}
提交代码
void _verifyPhoneNumber() async {
final PhoneVerificationCompleted verificationCompleted =
(AuthCredential phoneAuthCredential) async {
final FirebaseUser user =
await _auth.signInWithCredential(phoneAuthCredential);
if (user != null) {
phone = user.phoneNumber;
fid = user.uid;
saveLogin(context);
} else {
_showErrorDialog("User Verification Error!");
}
};
final PhoneVerificationFailed verificationFailed =
(AuthException authException) {
_showErrorDialog("Phone Verification Failed");
};
final PhoneCodeSent codeSent =
(String verificationId, [int forceResendingToken]) async {
_verificationId = verificationId;
setState(() {
_title = "Verify SMS Code";
phoneInput = false;
phoneSubmit = false;
codeInput = true;
codeSubmit = true;
});
};
final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
(String verificationId) async {
_verificationId = verificationId;
setState(() {
_title = "Verify SMS Code";
phoneInput = false;
phoneSubmit = false;
codeInput = true;
codeSubmit = true;
});
};
await _auth.verifyPhoneNumber(
phoneNumber: "+880" + _mobileNumber,
timeout: const Duration(seconds: 5),
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: codeSent,
codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
}
使用的插件
google_sign_in:^ 4.0.1 + 3
firebase_auth:^ 0.11.0
答案 0 :(得分:0)
尝试将REVERSE_CLIENT_ID自定义URL方案添加到您的Xcode项目中。
根据firebase文档:
iOS设置说明:如果您使用的设备上未使用模拟器(其中APN不起作用)或未设置APN,则应用程序验证可能会使用APN,您必须将URL方案设置为GoogleServices-Info的REVERSE_CLIENT_ID。 plist文件。
如何在Xcode项目中添加自定义URL方案:
从这里引用: