我正在努力实现与苹果的签到王国. 我已经完成了文档中的配置:https://www.mongodb.com/docs/atlas/app-services/authentication/apple/#std-label-apple-id-authentication
现在我正在try 添加苹果按钮和流程的登录.
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)
}
每当我try 使用Apple登录按钮进行登录时,我都会得到这样的异常:
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
你知道为什么会发生这种例外情况吗?