gpt4 book ai didi

objective-c - 无法获取 credential.state 和 getCredentialStateForUserID

转载 作者:行者123 更新时间:2023-12-03 14:00:59 25 4
gpt4 key购买 nike

我无法从方法 getCredentialStateForUserID 获取 credentialState 而其他成员返回良好。

我在 iPhone 8、iOS 13 模拟器上运行了该应用程序。

- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization {

if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {
ASAuthorizationAppleIDCredential *credential = authorization.credential;

NSString *state = credential.state;
NSString *userID = credential.user;
[[NSUserDefaults standardUserDefaults] setValue:userID forKey:currentAppleId];

NSPersonNameComponents *fullName = credential.fullName;
NSString *email = credential.email;
NSString *authorizationCode = [[NSString alloc] initWithData:credential.authorizationCode encoding:NSUTF8StringEncoding];
// refresh token

NSString *identityToken = [[NSString alloc] initWithData:credential.identityToken encoding:NSUTF8StringEncoding];
// access token

ASUserDetectionStatus realUserStatus = credential.realUserStatus;

NSLog(@"state: %@", state);
NSLog(@"userID: %@", userID);
NSLog(@"fullName: %@", fullName);
NSLog(@"email: %@", email);
NSLog(@"authorizationCode: %@", authorizationCode);
NSLog(@"identityToken: %@", identityToken);
NSLog(@"realUserStatus: %@", @(realUserStatus));

ASAuthorizationAppleIDProvider *appleIDProvider = [ASAuthorizationAppleIDProvider new];

if (userID) {
NSString* __block errorMsg = nil;
[appleIDProvider getCredentialStateForUserID:userID completion:^(ASAuthorizationAppleIDProviderCredentialState credentialState, NSError * _Nullable error) {
switch (credentialState) {
case ASAuthorizationAppleIDProviderCredentialRevoked:
errorMsg = @"revoked";
break;
case ASAuthorizationAppleIDProviderCredentialAuthorized:
errorMsg = @"completed well";
break;
case ASAuthorizationAppleIDProviderCredentialNotFound:
errorMsg = @"credential not found";
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"SignInWithApple state");
NSLog(@"%@", errorMsg);
});
}];
}
}
}

状态:(空)

realUserStatus: 1 (ASUserDetectionStatusUnknown)

为什么我会收到这个不适当的值?
任何其他值都能很好地返回。

我收到这个错误

2019-09-09 16:28:05.859082+0900 AppleSignin[57581:3353025] [core] Credential State 请求返回错误:Error Domain=AKAuthenticationError Code=-7001 "(null)"

最佳答案

我也遇到了同样的情况,经过一些测试,我发现当我使用设备进行测试时它开始工作了。此外,在模拟器上,它每次都会询问姓名/电子邮件,即使用户已经同意。当我切换到设备时,这也得到了解决:第一次之后,用户不会被要求再次授予权限,而是必须提供他的 PIN/密码才能登录。
希望这可以帮助!

关于objective-c - 无法获取 credential.state 和 getCredentialStateForUserID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57849628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com