Search code examples
androidfirebasefirebase-authenticationpassword-protectionpassword-recovery

Android Firebase Auth: verify account and reset password within the App


I'm creating an App with the Firebase as a backend. Everything seems nice and smooth, but there are some questions concerning the Authentication.

  1. FirebaseUser.sendEmailVerification() method sends an email which contains a link, that opens an INTERNET browser. It works fine, but is it possible to redirect and manage verification in the App ? Browser seems to be redundant in this work-flow.

  2. Similarly, FirebaseAuth.sendPasswordResetEmail([email]) method uses a browser as the interface to change password. It'll be more convenient to change it within the App. Is there a way to do it?


Solution

  • You can have both sendEmailVerification and sendPasswordResetEmail send Firebase Dynamic Links with action codes directly to the app by passing an ActionCodeSettings option with canHandleCodeInApp set to true. Learn more about this here: https://firebase.google.com/docs/auth/android/passing-state-in-email-actions In that case you would need to detect the incoming app link, use FDL to parse the deep link, get the action code and mode and build your own UI to verify the email or reset the password. You can port this guide to Android for more on this: https://firebase.google.com/docs/auth/custom-email-handler