gpt4 book ai didi

ios - Google Amplify iOS 应用程序 -> NSUnknownKeyException

转载 作者:行者123 更新时间:2023-11-29 05:12:05 25 4
gpt4 key购买 nike

我正在尝试使用 AWSMobileClient 在 iOS 应用程序中使用 Cognito 提供的 Google 联合登录功能。我有最新的 amplify (4.11.0) 和 AWS 工具包。

我的 pod 文件中有以下内容:

pod 'AWSAPIGateway'
pod 'AWSMobileClient'
pod 'AWSAuthUI'
pod 'AWSUserPoolsSignIn'
pod 'GoogleSignIn'
pod 'AWSGoogleSignIn'

我使用标准AWSMobileClient初始化调用然后 showSignIn方法带来登录屏幕,但出现以下异常:

'NSUnknownKeyException', reason: '[<GIDSignIn 0x600003f19e00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key uiDelegate.'

我的awsconfiguration文件具有以下条目:

"GoogleSignIn": {
"Permissions": "email,profile,openid",
"ClientId-WebApp": "XXXXXXXXX-YYYYYYYYYYYYYY.apps.googleusercontent.com",
"ClientId-iOS": "ZZZZZZZZZZZ-VVVVVVVVVVVVV.apps.googleusercontent.com"
}

这是在我创建身份验证后端时由 amplify 生成的(以及用户池、身份等的其他条目)。我还在 Google 开发者网站上设置了必要的项目和凭据。

使用 Cognito 托管的 UI(浏览器 URL),我可以毫无问题地使用 google 登录,只是不使用 iOS 应用程序。

如果我删除 ClientId-iOS 条目,则不再出现异常,但登录屏幕没有 google 按钮。

最佳答案

不完全是答案,但这里有太多评论。

您的崩溃似乎发生在 file found here :

相关代码:

- (instancetype)initWithGoogleClientID:(NSString *)googleClientID {
if (self = [super init]) {
_semaphore = dispatch_semaphore_create(0);

NSOperationQueue *operationQueue = [NSOperationQueue new];
_executor = [AWSExecutor executorWithOperationQueue:operationQueue];

_signInViewController = nil;

_signInClient = [NSClassFromString(@"GIDSignIn") sharedInstance];
[self.signInClient setValue:self forKey:@"delegate"];
[self.signInClient setValue:self forKey:@"uiDelegate"]; // Crashes here
[self.signInClient setValue:googleClientID forKey:@"clientID"];
[self.signInClient setValue:@[AWSGoogleSignInProviderClientScope, AWSGoogleSignInProviderOIDCScope] forKey:@"scopes"];
}

return self;
}

我标记了您可能发生崩溃的行。

它正在尝试设置在GIDSignIn中看到的属性

// The object to be notified when sign in dispatch selection is finished.
@property(nonatomic, weak) id<GIDSignInUIDelegate> uiDelegate;

这只是粗略的一瞥,但是调用的 sharedInatance 是在后台线程上创建的,因此存在竞争问题导致问题的可能性。我建议在此区域设置一些断点,并进行测试以查看您所在的线程以及调用时哪些属性可用。

假设 SDK 出现问题,您可以创建一个问题,他们可能会修复它。

关于ios - Google Amplify iOS 应用程序 -> NSUnknownKeyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59584023/

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