Skip to content

Add TvOS support to the auth module. - #799

Open
dfoelster wants to merge 1 commit into
GitLiveApp:masterfrom
dfoelster:feature/auth-on-tvOs
Open

Add TvOS support to the auth module.#799
dfoelster wants to merge 1 commit into
GitLiveApp:masterfrom
dfoelster:feature/auth-on-tvOs

Conversation

@dfoelster

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.supportedTargets and created tvOS stub implementations for multifactor, phone auth, and error mapping
  • Extracted iOS-specific implementations (PhoneAuthProvider, MultiFactor, toAuthException, FirebaseAuthMultiFactorException) from appleMain into iosMain
  • Introduced expect/actual declarations in appleMain for getMultiFactor(), updatePhoneNumberInternal(), and toAuthException()

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.

Comment on lines +11 to +12
public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = Unit
public actual suspend fun unenroll(factorUid: String): Unit = Unit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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
Comment on lines +8 to +9
public actual open class FirebaseAuthMultiFactorException(message: String) : FirebaseAuthException(message)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added the copyright headers

@nbransby

nbransby commented Aug 4, 2026

Copy link
Copy Markdown
Member

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.

@nbransby nbransby closed this Aug 4, 2026
@nbransby

nbransby commented Aug 5, 2026

Copy link
Copy Markdown
Member

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. gradle.properties on master still reads:

firebase-auth.supportedTargets=ios,jvm,js,android

which is precisely the line this PR changes to ios,tvos,jvm,js,android. The presence of TargetPlatform.Tvos blocks in firebase-auth/build.gradle.kts is what misled me — those are conditional on the property above, so they never activate for auth.

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.

@nbransby nbransby reopened this Aug 5, 2026
This was referenced Aug 5, 2026
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.
@dfoelster
dfoelster force-pushed the feature/auth-on-tvOs branch from 511d84f to e9f8dc3 Compare August 5, 2026 15:48
@dfoelster

Copy link
Copy Markdown
Author

Rebased the changes and reduced my previous duplication regarding the auth error code mapping to keep it mostly in one place.

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.

4 participants