Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Firebase Auth #222

Closed
wants to merge 12 commits into from
Closed

Adding Firebase Auth #222

wants to merge 12 commits into from

Conversation

KevinSchildhorn
Copy link
Contributor

@KevinSchildhorn KevinSchildhorn commented Mar 28, 2024

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

minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 20201
versionName = "2.2.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

val clientId = properties.getProperty("clientId", "")
buildConfigField("String", "CLIENT_ID", clientId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the readme with instructions on how to set your clientID for both android and iOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the readme

@KevinSchildhorn
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants