Skip to content

FUIAuthDelegate is not called if the view is activated in a .sheet #1225

@acgacgacgacg

Description

@acgacgacgacg

Similar to #1198
I use the FirebaseAuthUI in SwiftUI. I wrapped it in a UIViewControllerRepresentable and implemented the makeCoordinator method to set the delegate like the following

struct AuthView: View {
  var body: some View {
    AuthViewControllerRepresentable()
  }
}

struct AuthViewControllerRepresentable: UIViewControllerRepresentable {
  ...
  func makeCoordinator() -> Coordinator {
    Coordinator()
  }

  func makeUIViewController(context: Context) -> UINavigationController {
    let authUI = FUIAuth.defaultAuthUI()!
    authUI.delegate = context.coordinator
    ...
  }

  class Coordinator: NSObject, FUIAuthDelegate {
    func authUI(
      _ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?
    ) {
      print("authUI called")
      }
  }
}

The FUIAuthDelegate is not called if it is activated inside a .sheet like the following

.sheet(isPresented: $showAuthViewSheet) {
      AuthView()
    }

However, the FUIAuthDelegate method will get called if it is a stand alone page.

I'm using v14.2.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions