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

FUIAuthDelegate methods not called in v.14 #1198

Closed
joaomvfsantos opened this issue Aug 14, 2024 · 15 comments · Fixed by #1200 or #1203
Closed

FUIAuthDelegate methods not called in v.14 #1198

joaomvfsantos opened this issue Aug 14, 2024 · 15 comments · Fixed by #1200 or #1203
Assignees

Comments

@joaomvfsantos
Copy link

joaomvfsantos commented Aug 14, 2024

Problem: FUIAuthDelegate methods are not being called anymore in v.14. I have setup two example projects with the same code, one with FirebaseUI v.13 and another with FirebaseUI v.14. On version 13 it works correctly, and on version 14 not anymore.

Specifically the function that is not being called can be found in the AppDelegate file:

func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?)

Xcode 15.4
macOS 14.6.1 (Sonoma)
Using Swift Package Manager

Example with Firebase 14 where the issue exists: https://github.com/joaomvfsantos/FirebaseUITest/tree/fuiauthdelegate-issue (please use branch fuiauthdelegate-issue)

Example with Firebase 13 where it works: https://github.com/joaomvfsantos/FirebaseUITest/tree/fuiauthdelegate-issue-v13 (please use branch fuiauthdelegate-issue-v13)

Note: Please setup the GoogleService-Info.plist in the projects and the URL types and GIDClientID in the Info.plist before running the projects

@paulb777 paulb777 self-assigned this Aug 14, 2024
@paulb777
Copy link
Member

Thanks for the thorough repros! #1200 should fix.

@joaomvfsantos
Copy link
Author

Hello @paulb777 Unfourtunatly this seems not to be fixed. I updated the code to use 14.2.2 but the delegate method still does not get called. Maybe I'm missing something else here?

@paulb777
Copy link
Member

Hi @joaomvfsantos I appreciate your persistence. While #1200 fixed signing in, I'm able to reproduce the delegate method not being called. For some reason [self.delegate respondsToSelector:@selector(authUI:didSignInWithUser:error:)] fails in FirebaseUI 14 and succeeds in FirebaseUI 13 with seemingly the same delegate.

I'll reopen and continue to investigate.

@paulb777 paulb777 reopened this Aug 16, 2024
@paulb777
Copy link
Member

Removing the respondsToSelector test reveals a Google Utilities AppDelegate Swizzler problem:

Screenshot 2024-08-16 at 4 09 53 PM

@paulb777
Copy link
Member

I disabled swizzling and it still fails to find the selector:

'-[FirebaseUITest.AppDelegate authUI:didSignInWithAuthDataResult:error:]: unrecognized selector sent to instance 0x600000228a20'

Very weird since it's the exact same selector that works in FirebaseUI 13 .....

@paulb777
Copy link
Member

I found the issue, a fix, and published v14.2.4

@joaomvfsantos
Copy link
Author

@paulb777 I confirm it works. Thanks!

On a side note, because of the new @objc requirement I'm not sure if the sample code need to be updated, but I trust your judgment.

@paulb777
Copy link
Member

@joaomvfsantos Good to hear! Good catch on the sample, too. Thanks. #1205

@ShaiAlkoby
Copy link

ShaiAlkoby commented Sep 6, 2024

@paulb777 hey,
I've added @objc and I get a compilation error, any idea why?
image

@paulb777
Copy link
Member

paulb777 commented Sep 6, 2024

There may be a difference between Xcode versions. Does the last "Fix" suggestion help?

@ShaiAlkoby
Copy link

nope
image

@taiking
Copy link

taiking commented Sep 12, 2024

I am experiencing the same issue in the Swift environment of Xcode 15.2.

@ShaiAlkoby
Copy link

also happens in Xcode 16. @paulb777 any suggestions?

@paulb777
Copy link
Member

Please open another issue with a reproducible example and we can investigate.

@acgacgacgacg
Copy link

acgacgacgacg commented Jan 2, 2025

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 makeUIViewController(context: Context) -> UINavigationController {
    let authUI = FUIAuth.defaultAuthUI()!
    authUI.delegate = context.coordinator

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

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