SwiftUI (5.3) "Apple sign in"

134 Views Asked by At

I am trying to implement SwiftUI (5.3) "Apple sign in" with Apple sign-in/up button. Sharing my code, please help me figure out what's the problem with this code. NavigationLink destination is reaching just after clicking apple sign-in button, without showing/asking credentials.

import SwiftUI
import CoreData
import AuthenticationServices


struct ContentView: View {
    @State private var isUserAuthed = false
    @State private var user: UserAuth = UserAuth()


    var body: some View {
        NavigationView{
            NavigationLink(destination: HomeView(), isActive: $isUserAuthed){
                SignInWithAppleButton(
                    .signIn,
                        onRequest: { request in
                            request.requestedScopes = [.fullName, .email]
                        },
                        onCompletion: { result in
                            switch result {
                            case .success (let authResults):
                                print("---Authorization successful.")
                                isUserAuthed = true
                            case .failure (let error): 
                                print("Authorization failed: " + error.localizedDescription)
                            }
                        }
                ).frame(width: 300, height: 50, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)                                                           
            }
0

There are 0 best solutions below