Add TvOS support to the auth module. - #799
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds tvOS support to the firebase-auth module by splitting Apple-platform-specific code (multifactor, phone auth, error handling) from appleMain into iosMain and tvosMain source sets. On tvOS, unsupported features (phone auth, multifactor) throw UnsupportedOperationException.
Changes:
- Added tvOS to
firebase-auth.supportedTargetsand created tvOS stub implementations for multifactor, phone auth, and error mapping - Extracted iOS-specific implementations (
PhoneAuthProvider,MultiFactor,toAuthException,FirebaseAuthMultiFactorException) fromappleMainintoiosMain - Introduced
expect/actualdeclarations inappleMainforgetMultiFactor(),updatePhoneNumberInternal(), andtoAuthException()
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle.properties | Add tvos to firebase-auth supported targets |
| gradle/libs.versions.toml | Bump Kotlin version 2.2.20 → 2.2.21 |
| firebase-auth/src/appleMain/.../auth.kt | Extract error mapping and multifactor exception to expect declarations |
| firebase-auth/src/appleMain/.../credentials.kt | Move PhoneAuthProvider out to iosMain/tvosMain |
| firebase-auth/src/appleMain/.../user.kt | Add expect functions for multiFactor and updatePhoneNumber |
| firebase-auth/src/iosMain/.../auth.kt | iOS actual for error mapping with full multifactor support |
| firebase-auth/src/iosMain/.../credentials.kt | iOS actual for PhoneAuthProvider |
| firebase-auth/src/iosMain/.../multifactor.kt | iOS actual for multifactor classes |
| firebase-auth/src/iosMain/.../user.kt | iOS actual for getMultiFactor and updatePhoneNumber |
| firebase-auth/src/tvosMain/.../auth.kt | tvOS error mapping (no multifactor error codes) |
| firebase-auth/src/tvosMain/.../credentials.kt | tvOS PhoneAuthProvider stub (throws) |
| firebase-auth/src/tvosMain/.../multifactor.kt | tvOS multifactor stubs (mostly throws) |
| firebase-auth/src/tvosMain/.../user.kt | tvOS stubs for user multifactor/phone |
You can also share your feedback on Copilot code review. Take the survey.
| public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = Unit | ||
| public actual suspend fun unenroll(factorUid: String): Unit = Unit |
There was a problem hiding this comment.
@nbransby thoughts on this approach? i assume we want to really be as thin as possible and just let sdk throw the exception if its not implemented.
|
|
||
| internal actual fun FirebaseUser.getMultiFactor(): MultiFactor = MultiFactor() | ||
|
|
||
| internal actual suspend fun FirebaseUser.updatePhoneNumberInternal(credential: PhoneAuthCredential): Unit = Unit |
| public actual open class FirebaseAuthMultiFactorException(message: String) : FirebaseAuthException(message) | ||
|
|
There was a problem hiding this comment.
The FIRMultiFactorResolver class does not exist in the tvOS sdk references to it would not compile
| @@ -0,0 +1,35 @@ | |||
| package dev.gitlive.firebase.auth | |||
|
Thanks for putting this together, and apologies for the slow response. tvOS, macOS and iosX64 support landed in #770, which covered the auth module — so this is superseded by what's already on master. Appreciate the contribution. |
|
Reopening — this was closed in error on my side. It was closed as superseded by #770, on the basis that tvOS support had already landed. That was wrong. #770 added the tvOS/macOS machinery and enabled it for most modules, but not for firebase-auth. which is precisely the line this PR changes to So this is still needed, and it's the outstanding gap in #654. Apologies for the round trip, @dfoelster. It will need a rebase before it can go in:
No rush, and thanks for your patience on this one. |
There are some parts of the public api, that are not existing in the TvOS sdk. Mostly relating to auth via phone number or multifactor. Those methods will throw an UnsupportedOperationException with this change.
511d84f to
e9f8dc3
Compare
|
Rebased the changes and reduced my previous duplication regarding the auth error code mapping to keep it mostly in one place. |
There are some parts of the public api that are not existing in the TvOS sdk. Mostly relating to auth via phone number or multifactor. Those methods will throw an UnsupportedOperationException with this change.
But it allows for authenticated usage of already supported modules.