swiftui - SwiftUI (5.3) “苹果登录”
问题描述
我正在尝试使用 Apple 登录/向上按钮实现 SwiftUI (5.3)“Apple 登录”。分享我的代码,请帮我弄清楚这段代码有什么问题。NavigationLink 目标在单击苹果登录按钮后立即到达,而不显示/询问凭据。
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@*/)
}
解决方案
推荐阅读
- java - Android App 未通过 Firebase FCM 收到推送通知
- f# - 在 Dapper 中获取 QueryMultipleAsync 以使用 F#
- python - 有没有办法用pynput在python中引用退格?
- python - 如何将 pandas 数据框的元素组合为坐标对?
- java - 如果日期无效,我如何让 java 日期不会自动转换
- php - wordpress 按 acf 字段中保存的值排序帖子
- c# - 如何从 C# 中的 Windows10Forms 获取按钮句柄?
- python - 未安装 SDK 管理器
- ios - Xcode:如何更改 TabBar 中的“默认”选项卡
- python - 为什么列表结果与预期不同?