I developed an app with Flutter and Firebase that uses the phone authentication feature for Android and IOS. Everything works as expected except that the recaptcha is showing for Android.
To solve this, it says in the documentation that we need to use SafetyNet, however, it is impossible now to enable it from Firebase AppChecker since it’s deprecated. I have been using the new Play Integrity API that is supposed to replace SafetyNet but it doesn’t seem to work at the moment (the recaptcha is visible).
If someone has a solution, please share it!
Thank you in advance for your time 🙏
3
Answers
You’re right: the SafetyNet API is deprecated and cannot be used for newly created projects after 31 January 2023.
Unfortunately, the Play Integrity API cannot handle OTP authentication at the moment. The Google Support wrote me:
The solution is to further use the SafetyNet Attestation API. You have to apply for this. The process took around three weeks for my project.
If you got approved, you have to go to the library page in your Google API Console and activate the "Android Device Verification API".
With the following project setup it should work and you shouldn’t see the recaptcha anymore:
Note: the process is independent of using Flutter and is the same for e.g. also React Native or Android projects.
I faced a lot of issues with Google Authentication Service. Sometimes, OTPs don’t come through properly. My suggestion is to go for third-party API services instead, as this can lead to less code. Some of the third-party phone authentication services include:
2 Factor
Text Local
These services offer phone authentication solutions and can be used as alternatives to Google Authentication Service.
I was having a similar challenge but this was happening during development however, after deploying it to playstore it stopped. Firebase phone authentication is not suppose to require reCAPTCHA but if you experiencing this then probably:
Solution: Whitelist the number you using for the authentication when in development.
Solution: Use a different number for the authentication.