So I made this Apple sign-in button and it gives a response that's not the problem actually. The main problem appears when you choose your mail to sign in and it gets stuck in there.
import AuthenticationServices
struct SignInApple: View {
@State var isActive = false
@Environment(\.colorScheme) var colorScheme
@AppStorage("email") var email: String = ""
@AppStorage("firstName") var firstName: String = ""
@AppStorage("lastName") var lastName: String = ""
@AppStorage("userId") var userId: String = ""
@State var isActive2 = false
var body: some View {
NavigationView{
NavigationLink(destination: HomeView().navigationBarBackButtonHidden(true).navigationBarHidden(true), isActive: $isActive){
SignInWithAppleButton(.continue) {request in
request.requestedScopes = [.email, .fullName]
} onCompletion: { result in
switch result {
case .success(let auth):
switch auth.credential {
case let credential as ASAuthorizationAppleIDCredential:
let email = credential.email
let firstName = credential.fullName?.givenName
let lastName = credential.fullName?.familyName
let userId = credential.user
self.email = email ?? ""
self.userId = userId ?? ""
self.firstName = firstName ?? ""
self.lastName = lastName ?? ""
default:
break
}
case .failure(let error):
print(error.localizedDescription)
}
}.signInWithAppleButtonStyle(colorScheme == .dark ? .white : .black).cornerRadius(16).frame(width: 30, height: 130)
}
}
}
}
struct TestArea_Previews: PreviewProvider {
static var previews: some View {
SignInApple()
}
}