ios – Is there any way to correct this authentication problem?


I am trying to implement a connection of my application in SwiftUI with Google Drive, I have created the project in Google and I already have the client ID, but when I authenticate, I get this message.”Thread 1: “uiDelegate must either be to |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|.” I am using Xcode 15.1 and Swift 5.9.2.

// I try to do the authentication from the contentview
import SwiftUI
import GoogleSignIn
struct ContentView: View {
@StateObject private var googleDriveManager = GoogleDriveManager()

var body: some View {
    VStack {
        if googleDriveManager.isSignedIn {
            Text("Usuario autenticado")
        } else {
            Button("Iniciar sesión con Google") {
                googleDriveManager.authenticate()
            }
        }
    }
    .onAppear {
        // Establecer el uiDelegate al rootViewController
        GIDSignIn.sharedInstance().uiDelegate = UIApplication.shared.windows.first?.rootViewController as? UIViewController as? any GIDSignInUIDelegate
    }
}

}

// The app stops working when I press the button and I get the error mentioned

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img