DroidconKotlin icon indicating copy to clipboard operation
DroidconKotlin copied to clipboard

Adding Firebase Auth

Open KevinSchildhorn opened this issue 1 year ago • 1 comments

Adding support for Firebase Authentication

Adds a Login/Logout button in the settings screen, that will authenticate with google sign-in using Firebase. Then the user state is sent to the common code, to be used later.

Shared Code

  • Adding UserContext and UserData for commonly saved user information
  • Currently passing this information to the UserIdProvider for now, will be handled later
  • Adding abstract AuthenticationService for calling for sign in / sign out from common ui to platform specific code
  • Passing AuthenticationService into SettingsViewModel and using that for compose calls

Platform Code

  • Adding new Id "co.touchlab.droidconauthtest" for testing
  • Adding FirebaseAuth to android and iOS using Gradle and CocoaPods
  • Adding FirebaseService which is implementation of AuthenticationService for each platform, to handle authentication
  • Adding authentication listener in MainActivity and AppDelegate to save changes to the common code
  • Adding the ClientID as a secret in Android. Not sure if this is needed

TODO

We are unsure about saving the clientID in public or as a secret. In android it is already a secret, however in iOS it's added in a URLScheme so it's more challenging to keep secret. Will look into this more.

Proof

Note for Android emulator you'll need to be signed into your emulator

Simulator Screen Recording - iPhone 15 Pro - 2024-03-28 at 12 29 38

Screen_recording_20240328_124442.webm

KevinSchildhorn avatar Mar 28 '24 16:03 KevinSchildhorn

Updated style

signed in signed out
android Screenshot_20240402_105704 Screenshot_20240402_105712
ios Simulator Screenshot - iPhone 15 Pro - 2024-04-02 at 11 13 28 Simulator Screenshot - iPhone 15 Pro - 2024-04-02 at 11 06 57

KevinSchildhorn avatar Apr 02 '24 15:04 KevinSchildhorn