Flutter Flatter Firebase手机认证仅适用于Android,不适用于iOS
我正在做一个新的flifter项目,我需要用Firebase实现电话认证 我刚刚完成了这部分代码的开发,并在实际设备上进行了测试 这里有我用来验证电话号码的功能:Flutter Flatter Firebase手机认证仅适用于Android,不适用于iOS,flutter,firebase-authentication,Flutter,Firebase Authentication,我正在做一个新的flifter项目,我需要用Firebase实现电话认证 我刚刚完成了这部分代码的开发,并在实际设备上进行了测试 这里有我用来验证电话号码的功能: _verifyPhone() async { print("Estoy en veryfyphone "+'+34${widget.phone}'); await FirebaseAuth.instance.verifyPhoneNumber( phoneNumber: '+34${
_verifyPhone() async {
print("Estoy en veryfyphone "+'+34${widget.phone}');
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: '+34${widget.phone}',
verificationCompleted: (PhoneAuthCredential credential) async {
await FirebaseAuth.instance
.signInWithCredential(credential)
.then((value) async {
if (value.user != null) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => Dashboard()),
(route) => false);
}
});
},
verificationFailed: (FirebaseAuthException e) {
print(e.message);
},
codeSent: (String verficationID, int resendToken) {
setState(() {
_verificationCode = verficationID;
});
},
codeAutoRetrievalTimeout: (String verificationID) {
setState(() {
_verificationCode = verificationID;
});
},
timeout: Duration(seconds: 120));
}
这里有一段代码,它使用PinPut小部件处理收到的SMS代码:
PinPut(
fieldsCount: 6,
textStyle: const TextStyle(fontSize: 25.0, color: Colors.white),
eachFieldWidth: 40.0,
eachFieldHeight: 55.0,
focusNode: _pinPutFocusNode,
controller: _pinPutController,
submittedFieldDecoration: pinPutDecoration,
selectedFieldDecoration: pinPutDecoration,
followingFieldDecoration: pinPutDecoration,
pinAnimationType: PinAnimationType.fade,
onSubmit: (pin) async {
try {
await FirebaseAuth.instance
.signInWithCredential(PhoneAuthProvider.credential(
verificationId: _verificationCode, smsCode: pin))
.then((value) async {
if (value.user != null) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => Dashboard()),
(route) => false);
}
});
} catch (e) {
FocusScope.of(context).unfocus();
_scaffoldkey.currentState
.showSnackBar(SnackBar(content: Text('invalid OTP')));
}
},
),
我的问题是,它只在该项目的Android应用程序上工作
启动iOS应用程序时,未收到短信
我已经为iOS实现了所有需要的设置