{"id":4534,"date":"2020-09-25T18:04:46","date_gmt":"2020-09-25T08:04:46","guid":{"rendered":"https:\/\/learntodroid.com\/?p=4534"},"modified":"2020-09-27T15:47:55","modified_gmt":"2020-09-27T05:47:55","slug":"how-to-use-firebase-authentication-in-an-android-app-using-mvvm","status":"publish","type":"post","link":"http:\/\/10.0.0.14:32769\/how-to-use-firebase-authentication-in-an-android-app-using-mvvm\/","title":{"rendered":"How to Use Firebase Authentication in an Android App using MVVM"},"content":{"rendered":"\n

Firebase Authentication simplifies the process of adding user sign in and registration functionality into your Android app. Firebase Authentication provides a backend and an SDK for managing user authentication in multiple different ways including using a simple email address and password.<\/p>\n\n\n\n

Model View ViewModel (MVVM) is a software architecture pattern that helps you structure your Android project into classes that provide a clear separation of concerns and improves the extensibility and maintainability of your code.<\/p>\n\n\n\n

I have put together this tutorial on how to use Firebase Authentication to add user registration, sign-in and sign-out functionality to an Android app while structuring the Android project using the MVVM design pattern.<\/p>\n\n\n\n

We will use multiple Android architecture components from the Jetpack library to implement this app including the navigation architecture component, ViewModel and LiveData.<\/p>\n\n\n\n

In order to create an Android app that uses Firebase Authentication that follows the MVVM design pattern we will need to:<\/strong><\/p>\n\n\n\n

  1. Retrieve Firebase Authentication and Jetpack dependencies for Navigation, LiveData and ViewModel using Gradle<\/strong><\/li>
  2. Create a Firebase project and enable email address and password authentication<\/strong><\/li>
  3. Implement a Repository that interacts with the Firebase SDK for registration, sign-in and sign-out<\/strong><\/li>
  4. Implement a ViewModel that interacts with the Repository for user sign-in and registration<\/strong><\/li>
  5. Implement a View that interacts with the ViewModel for user sign-in and registration<\/strong><\/li>
  6. Implement a ViewModel that interacts with the Repository for user sign-out<\/strong><\/li>
  7. Implement a View that interacts with the ViewModel for user sign-out<\/strong><\/li><\/ol>\n\n\n\n

    In this post, I will walk you through each of these steps in detail and provide code samples embedded in this blog post that are also available for free on GitHub<\/a>.<\/p>\n\n\n\n

    I have also created a video of this tutorial that is available on YouTube which I have embedded below.<\/p>\n\n\n\n

    \n
    https:\/\/www.youtube.com\/watch?v=FuAz-ahdk0E<\/a>