- 注:
- 需要真机进行测试
- 需要开发者账号
- 需要导入 import AuthenticationServices 库
- 需要在Capability中进行配置
一步一步来,先上代码
import SwiftUI
import AuthenticationServices// 一定要导入
struct ContentView: View {
@State private var message: String = "多行文本输入框"
var body: some View {
VStack{
SignInWithAppleButton(.signIn) { request in
request.requestedScopes = [.fullName,.email]//授权时显示的内容
} onCompletion: { result in
switch result{
case .success(let success):
print(success)
case .failure(let error):
print(error)
}
}
}
}
}
在Capability中进行配置
target -> Signing & Capabilities -> +Capability -> 搜索Sign In With Apple并添加
添加完底部会出现:
** 配置完就OK,记得在真机中测试即可~(不要用模拟器)*











网友评论