B4A Library Firebase phone number authentication

Here is my second lib, a wrap to integrate firebase auth phone number authentication.
It is working nicely on my app.
for reference visit: Authenticate with Firebase on Android using a Phone Number

FirebaseAuthPhone

Version: 1.9


Events:

  • phoneverification (success As Boolean, info As String)
  • phonesignedin (success As Boolean, User As FirebaseAuthPhoneUser, info As String)
  • oncodesent (success As Boolean, verificationid As String)
  • gettoken (success As Boolean, token As String, info As String)
Methods:
  • Initialize (eventName As String)
  • startPhoneNumberVerification (phoneNumber As String)
  • verifyPhoneNumberWithCode (verificationId As String, code As String)
  • currentToken ()
  • SignOut

Properties:
  • CurrentUser As FirebaseAuthPhoneUserWrapper [read only]


FirebaseAuthPhoneUser

Properties:

  • Anonymous As Boolean [read only]
  • IsInitialized As Boolean [read only]
  • ProviderData As List [read only]
  • ProviderId As String [read only]
  • Providers As List [read only]
  • Uid As String [read only]

Version1.8 released. It has been compiled with latest Firebase SDK and works with B4A 12.0+
Version1.9 released.Fixes a bug that caused application to crash when a wrong or expired code was entered.
 

Attachments

  • FirebaseAuthPhone_V1.9.zip
    13.1 KB · Views: 389
  • AuthSample.zip
    182.2 KB · Views: 373
Last edited:

Enrico Fuoti

Active Member
Licensed User
Longtime User
yes, i think the problem i haved in my project.

the captcha window, autoclose before select objects... ( anything from my app triger and close this window captcha )
is possible dissable windows captcha ?
I don't get the captcha request on my project. It may be related to a missing SHA-2 key
Try to go to your firebase project console and check SHA2 key. then re-download your google-services.json
 

scsjc

Well-Known Member
Licensed User
Longtime User
I don't get the captcha request on my project. It may be related to a missing SHA-2 key
Try to go to your firebase project console and check SHA2 key. then re-download your google-services.json

i have this configuration on firebase, not see SHA2, only see SHA-1 and SHA-256

1668163821339.png



The captcha asks me when it fires authphone_oncodesent .... with .... success=true and verificationid exists
the captcha that appears to me is to verify that a human is on the screen
 

scsjc

Well-Known Member
Licensed User
Longtime User
i have this configuration on firebase, not see SHA2, only see SHA-1 and SHA-256

View attachment 135893


The captcha asks me when it fires authphone_oncodesent .... with .... success=true and verificationid exists
the captcha that appears to me is to verify that a human is on the screen

yes i have a value in SHA-256
 
all the library versions before the 1.8 version do not work with b4a 12.
the 1.8 version has 2 problems 1st if we put the manual code wrong it is crashing, 2nd it is asking for a captcha every time we need to do verification.

i hope that you can find a solution for this issue

com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.auth.FirebaseAuthInvalidCredentialsException: The sms verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure use the verification code provided by the user.

at com.google.android.gms.tasks.zzu.getResult(com.google.android.gms:play-services-tasks@@17.2.0:15)

at anywheresoftware.b4a.FirebaseAuthPhone.FirebaseAuthPhoneWrapper$3.onComplete(FirebaseAuthPhoneWrapper.java:338)
 

Enrico Fuoti

Active Member
Licensed User
Longtime User
all the library versions before the 1.8 version do not work with b4a 12.
the 1.8 version has 2 problems 1st if we put the manual code wrong it is crashing, 2nd it is asking for a captcha every time we need to do verification.

i hope that you can find a solution for this issue
Hello Madrigal,
The 1.8 version is compiled with latest firebase sdk. I tested with sample project and worked fine. I did not get the errors you mentioned.
download the apk in the following link and test it. let me know if it works on your device,
It is compiled with b4a 12.
https://www.dropbox.com/s/bgn8isn5eyr9d0c/authsample.zip?dl=1
If it works, the problem may be in firebase sdk. It looks like there is an issue with it that affects apps that are published on playstore and have a long name.
 
Hello Madrigal,
The 1.8 version is compiled with latest firebase sdk. I tested with sample project and worked fine. I did not get the errors you mentioned.
download the apk in the following link and test it. let me know if it works on your device,
It is compiled with b4a 12.
https://www.dropbox.com/s/bgn8isn5eyr9d0c/authsample.zip?dl=1
If it works, the problem may be in firebase sdk. It looks like there is an issue with it that affects apps that are published on playstore and have a long name.
the example that you sent me takes the phone number from the device and does auto verification, this is working fine with me, my case is if we want to enter the verification code manually if i put the code correct there is no problem but if i put the code wrong the app crashes.
pls note i made sure that i have the correct sdk and all i have downloaded is correct

kindly try the case that i am asking about once you put the code wrong

thank you
 

Enrico Fuoti

Active Member
Licensed User
Longtime User
the example that you sent me takes the phone number from the device and does auto verification, this is working fine with me, my case is if we want to enter the verification code manually if i put the code correct there is no problem but if i put the code wrong the app crashes.
pls note i made sure that i have the correct sdk and all i have downloaded is correct

kindly try the case that i am asking about once you put the code wrong

thank you
I added a new version on first post that should have fixed the bug.
 

hitesh.k

Member
Hello thanks for lib is authsample program is working because i am getting error invalid phone number. when i check in loger phone number was not starting with + sign so i manualy add that then error came
 

Attachments

  • Screenshot_20230311_163933.jpg
    Screenshot_20230311_163933.jpg
    293 KB · Views: 179

Enrico Fuoti

Active Member
Licensed User
Longtime User
Hello Hitesh,
I think is better to start a new thread for this.
The message refers to a SafetyNet verification problem.
This is normally happens when you did not set both SHA1 and SHA256 keys correctly,
but if you're testing the authsample demo, this is not the case.
The authsample works nicely on my phone.
Normally you sould not need to manually add/edit phone number,
it looks like in some phones the number is returned without international prefix
Firebase needs the number in international format having + country code at beginning.
Are you testing on a real device or emulator?
Have you tested the authsample on a second phone ?
 

Enrico Fuoti

Active Member
Licensed User
Longtime User
Hitesh,
I'm not sure, to understand, what exactly happens with your phone.
We should also verify if your country or phone provider is supported by Firebase.
please create a new thread or write me with a private message,
We'll try to identify the issue and a possible solution.
 

hitesh.k

Member
Hitesh,
I'm not sure, to understand, what exactly happens with your phone.
We should also verify if your country or phone provider is supported by Firebase.
please create a new thread or write me with a private message,
We'll try to identify the issue and a possible solution.
Ok thanks
 
Top