Android Flatter Firebase电话验证返回成功,但不';t发送短信代码验证
我开发了一个带有电话号码认证的android应用程序,当我在play store上发布它时,它就不再工作了 在调试版本中,我通过短信收到了一次代码,但它不再工作了 有了这个电话号码,它就工作了,只是不能用我的真实号码作为测试 1-在仪表板上启用对电话的访问 2-SHA-1设置在projet中Android Flatter Firebase电话验证返回成功,但不';t发送短信代码验证,android,firebase,flutter,authentication,Android,Firebase,Flutter,Authentication,我开发了一个带有电话号码认证的android应用程序,当我在play store上发布它时,它就不再工作了 在调试版本中,我通过短信收到了一次代码,但它不再工作了 有了这个电话号码,它就工作了,只是不能用我的真实号码作为测试 1-在仪表板上启用对电话的访问 2-SHA-1设置在projet中 buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter()
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-auth:19.3.2'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.android.support:multidex:1.0.3' //with support libraries
}
apply plugin: 'com.google.gms.google-services'
Future<void> verifyPhone() async {
final PhoneCodeSent smsOTPSent = (String verId, [int forceCodeResend]) {
print("smsOTPSent");
print(forceCodeResend);
print(verId);
this.verificationId = verId;
smsOTPDialog(context).then((value) {
print('sign in');
});
};
try {
await _auth.verifyPhoneNumber(
phoneNumber: "+55" + this.telController.text, // PHONE NUMBER TO SEND OTP
codeAutoRetrievalTimeout: (String verId) {
//Starts the phone number verification process for the given phone number.
//Either sends an SMS with a 6 digit code to the phone number specified, or sign's the user in and [verificationCompleted] is called.
this.verificationId = verId;
print("verId " + verId);
},
codeSent: smsOTPSent, // WHEN CODE SENT THEN WE OPEN DIALOG TO ENTER OTP.
timeout: const Duration(seconds: 20),
verificationCompleted: (AuthCredential phoneAuthCredential) {
print("verificationCompleted " + this.telController.text);
print(phoneAuthCredential);
},
verificationFailed: (AuthException exceptio) {
print("fail");
print('${exceptio.message}');
}).timeout(const Duration(seconds: 2));
} catch (e) {
handleError(e);
print(e.printStackTrace());
}
}
verificaLogado(){
print("chamou: verificaLogado()");
print(_auth.currentUser());
_auth.currentUser().then((user) {
if (user != null) {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/homepage');
}else{
print("não logado");
}
});
}
signIn() async {
try {
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: verificationId,
smsCode: smsOTP,
);
final FirebaseUser user = (await _auth.signInWithCredential(credential)).user;
final FirebaseUser currentUser = await _auth.currentUser().timeout(Duration(seconds: 5));
assert(user.uid == currentUser.uid);
_showDialog('Sucesso', 'Autenticado com o número de telefone ' + user.phoneNumber);
_setPhoneFCM(currentUser.uid, currentUser.phoneNumber);
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/homepage');
} catch (e) {
handleError(e);
print(e.printStackTrace());
}
}
buildscript{
ext.kotlin_版本='1.3.50'
存储库{
谷歌()
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle:3.5.0'
classpath'com.google.gms:googleservices:4.3.3'
classpath“org.jetbrains.kotlin:kotlin gradle plugin:$kotlin_version”
}
}
所有项目{
存储库{
谷歌()
jcenter()
}
}
依赖关系{
实现“org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_版本”
测试实现'junit:junit:4.12'
androidTestImplementation'androidx.test:runner:1.1.1'
AndroidTest实施“androidx.test.浓缩咖啡:浓缩咖啡核心:3.1.1”
实现'com.google.firebase:firebase分析:17.2.2'
实现'com.google.firebase:firebase auth:19.3.2'
实现“androidx.multidex:multidex:2.0.0”
实现'com.android.support:multidex:1.0.3'//带有支持库
}
应用插件:“com.google.gms.googleservices”
Future verifyPhone()异步{
final PhoneCodeSent smsOTPSent=(字符串verId,[int-forceCodeResend]){
印刷品(“smsOTPSent”);
打印(forcecode重新发送);
印刷(verId);
this.verificationId=verId;
smsOTPDialog(上下文)。然后((值){
打印(“登录”);
});
};
试一试{
等待_auth.verifyPhoneNumber(
电话号码:“+55”+this.telController.text,//发送OTP的电话号码
codeAutoRetrievalTimeout:(字符串验证){
//启动给定电话号码的电话号码验证过程。
//向指定的电话号码发送带有6位代码的短信,或在用户登录后呼叫[verificationCompleted]。
this.verificationId=verId;
打印(“verId”+verId);
},
codeSent:smsOTPSent,//当代码发送时,我们打开对话框进入OTP。
超时:常数持续时间(秒:20),
验证已完成:(AuthCredential电话AuthCredential){
打印(“verificationCompleted”+this.telController.text);
打印(电话认证);
},
验证失败:(AuthException异常){
打印(“失败”);
打印(“${exceptio.message}”);
}).超时(常数持续时间(秒:2));
}捕获(e){
handleError(e);
打印(例如printStackTrace());
}
}
核实{
打印(“chamou:verificaLogado()”;
打印(_auth.currentUser());
_auth.currentUser().then((用户){
如果(用户!=null){
Navigator.of(context.pop();
Navigator.of(context.pushReplacementNamed('/homepage');
}否则{
印刷品(“não logado”);
}
});
}
signIn()异步{
试一试{
最终AuthCredential凭据=PhoneAuthProvider.getCredential(
验证ID:verificationId,
smsCode:smsOTP,
);
最终FirebaseUser用户=(等待身份验证登录,使用凭证(凭证)).user;
final FirebaseUser currentUser=wait_auth.currentUser().超时(持续时间(秒:5));
断言(user.uid==currentUser.uid);
_showDialog('Sucesso'、'Auenticado com o número de telefone'+user.phoneNumber);
_setPhoneFCM(currentUser.uid、currentUser.phoneNumber);
Navigator.of(context.pop();
Navigator.of(context.pushReplacementNamed('/homepage');
}捕获(e){
handleError(e);
打印(例如printStackTrace());
}
}
我找到了解决方案;它位于SHA-1键上;在firebase中,我配置了我在Android Studio Keysol上获得的SHA-1;但当我在Google Play Store上发布应用程序时;他将SHA-1替换为另一把钥匙,以便在Play Store上交付应用程序;您可以在Google Play Console>发布管理>应用程序签名中找到新功能;应用程序内签名证书。
在firebase projet和wow中配置此项;它起作用了
1-在将每个版本发布到播放控制台上的曲目之前,请使用上载密钥对其进行数字签名。
2-Google Play使用上载证书验证您的身份,并使用应用程序的订阅密钥重新签署您的版本以进行分发。
3-每个Android设备在更新之前都会验证版本的应用程序签名证书是否与已安装应用程序的签名证书匹配
我找到了解决办法我找到了解决办法;它位于SHA-1键上;在firebase中,我配置了我在Android Studio Keysol上获得的SHA-1;但当我在Google Play Store上发布应用程序时;他将SHA-1替换为另一把钥匙,以便在Play Store上交付应用程序;您可以在Google Play Console>发布管理>应用程序签名中找到新功能;应用程序内签名证书。 在firebase projet和wow中配置此项;它起作用了 1-在将每个版本发布到播放控制台上的曲目之前,请使用上载密钥对其进行数字签名。 2-Google Play使用上载证书验证您的身份,并使用应用程序的订阅密钥重新签署您的版本以进行分发。 3-每个Android设备在更新之前都会验证版本的应用程序签名证书是否与已安装应用程序的签名证书匹配
我找到了解决方案我想我发现了问题,即使遵循了所有的指导原则并注册了测试电话号码,由于某种原因,我的网络IP在firebase服务器上被阻止。当我尝试使用手机的4G网络时,我想我发现了问题,即使遵循了所有的指导原则并注册了测试电话号码,由于某种原因,我的网络IP在firebase服务器上被阻塞了。当我尝试使用手机的4G网络时,它起了作用