我正在尝试使用苹果登录 Realm。 我已经从文档中进行了配置:https://www.mongodb.com/docs/atlas/app-services/authentication/apple/#std-label-apple-id-authentication
现在我正在尝试添加使用Apple按钮和流程登录。
SwiftUI 上的登录按钮:
SignInWithAppleButton(.signIn, onRequest: { request in
isLoggingIn = true
request.requestedScopes = [.email]
}, onCompletion: { result in
switch result {
case .success(let authResults):
guard let credentials = authResults.credential as? ASAuthorizationAppleIDCredential, let identityToken = credentials.identityToken,
let identityTokenString = String(data: identityToken, encoding: .utf8) else { return }
repo.loginwithApple(appleTokenIDString: identityTokenString) { user, error in
}
case .failure(let error):
isLoggingIn = false
}
})
repo.loginwithApple
从共享的 kotlin 存储库调用方法:
suspend fun loginwithApple(appleTokenIDString: String): User {
var credentials = Credentials.apple(idToken = appleTokenIDString)
return appService.login(credentials = credentials)
}
每当我尝试使用苹果登录按钮登录时,我都会收到此异常:
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SharedRealmRepo loginwithAppleAppleTokenIDString:completionHandler:]: unrecognized selector sent to instance 0x281fe4960'
terminating with uncaught exception of type NSException
知道为什么会发生异常吗?