颤振火基电话身份验证返回成功,但不发送短信验证码



我开发了一个带有电话号码验证的android应用程序,当我在play商店上发布它时,它不再工作了。

在调试版本中,我通过短信收到了一次代码,但它不再工作了。

有了这个电话号码,它就可以工作了,只是不能用我的真实号码作为测试

1-在仪表板上启用对电话的访问2-项目中设置了SHA-1

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());
}
}

我找到了解决方案;它在SHA-1密钥上;在firebase中,我配置了我在Android Studio密钥工具上得到的SHA-1;但当我在谷歌Play商店上发布应用程序时;他将SHA-1替换为另一个密钥,以便在Play Store上交付该应用程序;您可以在Google Play控制台中找到新功能>发布管理>应用程序签名;应用程序中的签名证书。在firebase项目中配置这个,哇;它正在发挥作用。

1-在将每个版本发布到播放控制台上的曲目之前,您可以使用上载密钥对其进行数字签名。2-Google Play使用上传证书来验证您的身份,并使用应用程序的订阅密钥对您的版本进行重新签名以进行分发。3-每个Android设备在更新之前都会验证版本的应用程序签名证书是否与已安装的应用程序的签名证书匹配。

我在这里找到了解决方案

最新更新