Current behavior:
Calling verifyPhoneNumber on android triggers instantverification however no code is sent in the credential object. I do get key verified: false though which means no verificationId and no code.
Edit: The PhoneAuth user account is being created on firebase console. So, there's no doubt that verification was succesful.
Expected behavior:
Expected behavior is to get code in the credential object when credential.instantVerification is true
Environment information
_Runtime issue_
_Android build issue:_
Related code:
window.FirebasePlugin.verifyPhoneNumber(phoneNumber, 0, (credential) => {
if(typeof credential === 'object') {
if(credential.instantVerification) {
console.log('instant verification')
console.log('credential.code', credential.code)
} else {
console.log('not instant verification')
}
}
}, (error) => {
console.log('error', error)
})
Console output
console output
instant verification
credential.code undefined
I think this line here is not returning correct field value or there might have been changes to PhoneAuthCredential on firebase api
There had been discussion about it on original repo about this. https://github.com/arnesson/cordova-plugin-firebase/pull/861
verifyPhoneNumber() has been reworked in v7.0.0 of this plugin which should resolve your issue.
Please retest using the example project.
You can use the newly added fakeVerificationCode option to test instant verification on Android which uses the officially sanctioned method - see the updated documentation for more details.
If you still encounter issues, please respond here and I will reopen the issue to investigate.
hey @dpa99c,
When I'm using the devices phone number I received instantVerification = true, without the verificationId or code. The expected output here would be with the verificationId and Code
When I'm using a phone number of a different device, I receive instantVerification = true along with the verificationId and a null code. The expected outcome here would be only the verificationId.
I've not developed any cordova plugins before but I'm going to see if I can create an PR for this.
@MattGould1 As you can see in the source code, instantVerification: true is only ever set in the onVerificationCompleted() callback which is the instant verification callback.
In my testing using the example project, this behaved as expected and when onVerificationCompleted() was called, the verificationId and code were resolved.
Could you try to reproduce the issue using the example project?
hey @dpa99c sorry, I didn't mention that was with https://github.com/dpa99c/cordova-plugin-firebasex-test
I get the same results within my actual project as well.
Here's a look at what onVerificationCompleted is receiving.
credential = {PhoneAuthCredential@8547}
zza = null
zzb = null
zzc = true
zzd = "PHONE_NUMBER"
zze = true
zzf = null
zzg = null
This is what is received when using a phone number where instant verification shouldn't be possible
credential = {PhoneAuthCredential@8575}
zza = "AM5PThDaZfNM63JRgqowSNAjLhHTZq8ceLYKQD8j9z1kcbcWzv9kQiFziy81ghjOmEFo1S88ml-4Rdfrw3LNjzcPoJ30I270ejNROXKs21YkbTjkxmt6oXULDw283OnLJGgCE5c3pvr1w3XKFfYZKR9DzlqVSPpRl2IzVjkceeDpR3VsFvtDkv3W2RNMPraK2wmZC1HeySoag-ixq7J4I6j1fBAFOO_feL2e5PhnGjSbsRkS8s0"
zzb = "null"
zzc = false
zzd = null
zze = true
zzf = null
zzg = null
I can still confirm that the credential.code and credential.verificationId are not resolved although onVerificationCompleted gets called.
As I mentioned in earlier comment, there has been some changes to firebase API such that the private fields like code and verificationId of PhoneAuthCredential are hard to retrieve. I tried playing with it but couldn't get those fields.
Here is the source code which might need modifications: https://github.com/dpa99c/cordova-plugin-firebasex/blob/master/src/android/FirebasePlugin.java#L818:L827
Mind that I tried trigerring instant verification in a real android device instead of setting up test phone number in firebase console.
quick update, if this helps I'm able to sign in with the credential using FirebaseAuth.getInstance().signInWithCredential(credential)
but the credential is still missing the verificationId and code.
hey @dpa99c,
The only way to get this functionality to work for me was by implementing the native signInWithCredential method. After that, I implemented a native function to get the users idToken and then used the idToken to verify with my server.
I am also encountering the same issue, I'm using plugin version v7.0.1
The only field I get at the credential object is instantVerification with true value, while credential.code and credential.verificationId field still not found

The internal reflection approach inherited from cordova-plugin-firebase is the issue here.
There is no reason to extract the credentials from the native Java credential object and return it to the JS layer.
So I will rework the implementation of verifyPhoneNumber() as part of #208 to retain the credential in the native layer on both Android & iOS, which is a more stable approach.
However, be warned this will make breaking changes to the plugin API.