简体   繁体   English

为什么无法使用苹果按钮登录?

[英]Why isn't sign in with apple button working?

When I drag out the SignInWithAppleButton control using swiftui, this is the code that is shown.当我使用 swiftui 拖出 SignInWithAppleButton 控件时,显示的代码如下。 However, I get the error message "Argument passed to call that takes no arguments".但是,我收到错误消息“传递给不带参数的调用的参数”。 The compiler only allows the project to build when SignInWithAppleButton() is used.编译器仅允许在使用 SignInWithAppleButton() 时构建项目。

I've found lots of code online that uses the below format.我在网上发现了很多使用以下格式的代码。 Why isn't it working now?为什么它现在不起作用? What is the correct alternative if onRequest and onCompletion can't be used?如果不能使用 onRequest 和 onCompletion,正确的选择是什么?

            SignInWithAppleButton(
            onRequest: { request in
                
            },
            onCompletion: { result in
                
            }
        )

works for me on macos 12.beta using xcode 13.beta, target ios 14.5 and macCatalyst 11.3.使用 xcode 13.beta,目标 ios 14.5 和 macCatalyst 11.3 在 macos 12.beta 上为我工作。 What system are you using?你用的是什么系统?

import SwiftUI
import AuthenticationServices

@main
struct TestApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
struct ContentView: View {
    var body: some View {
        SignInWithAppleButton(onRequest: { request in
             print("onRequest")
         },
         onCompletion: { result in
            print("onCompletion")
         }
        ).frame(width: 222, height: 66)
    }
}

When I drag out the SignInWithAppleButton control using swiftui, this is the code that is shown.当我使用 swiftui 拖出 SignInWithAppleButton 控件时,这是显示的代码。 However, I get the error message "Argument passed to call that takes no arguments".但是,我收到错误消息“传递给不带参数的调用的参数”。 The compiler only allows the project to build when SignInWithAppleButton() is used.编译器仅在使用 SignInWithAppleButton() 时才允许构建项目。

I've found lots of code online that uses the below format.我在网上找到了很多使用以下格式的代码。 Why isn't it working now?为什么现在不工作了? What is the correct alternative if onRequest and onCompletion can't be used?如果 onRequest 和 onCompletion 不能使用,正确的选择是什么?

            SignInWithAppleButton(
            onRequest: { request in
                
            },
            onCompletion: { result in
                
            }
        )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM