Login with LoginType.PHONE only completes the promise for the first time
See original GitHub issuePlatform: Android
firebase.login({
type: firebase.LoginType.PHONE,
phoneOptions: {
phoneNumber: '+37011'
}
}).catch(error => {
console.log(error);
});
First time this works as expected, failing and rejecting the promise, console.log
outputing the error message. Second time the promise is not rejected.
I’ve debugged this all the way to firebase.android.js
, this line:
var OnVerificationStateChangedCallbacks = com.google.firebase.auth.PhoneAuthProvider.OnVerificationStateChangedCallbacks.extend({
The callbacks work as expected and actually call reject(errorMessage);
but for some reason after the first failure any subsequent calls will not reject the promise.
I would be willing to help in fixing this (if indeed it is a bug) but I’m pretty new to Nativescript and mobile development and not sure what the extend()
call is or how to debug native code. It seems to be the root of the problem. I have tried calling the callback directly on the object returned by extend
and could reproduce.
UPDATE:
Isolated reproduction. Please note that it doesn’t matter if it’s a resolve
or reject
- it only works the first time.
reproduce().catch(console.log);
function reproduce() {
return new Promise((resolve, reject) => {
var OnVerificationStateChangedCallbacks = com.google.firebase.auth.PhoneAuthProvider.OnVerificationStateChangedCallbacks.extend({
onVerificationCompleted: (phoneAuthCredential) => {
resolve(phoneAuthCredential);
},
onVerificationFailed: function (firebaseException) {
reject(firebaseException);
}
});
const cbs = new OnVerificationStateChangedCallbacks();
cbs.onVerificationFailed('something went wrong');
});
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
I guess that would make it easier for me so sure why not!
Could be related https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/462