用户池未注册

时间:2017-02-08 14:51:47

标签: swift aws-sdk

将我的所有AWS SDK加载到我的项目中以实现登录过程后,我收到此错误。所有文件都装得很好。 有谁知道我可能错过了什么?

感谢您的帮助

2017-02-08 16:37:05.799 ClientService2[37948:950374] Presenting view controllers on detached view controllers is discouraged <ClientService2.ClientListTableViewController: 0x7fafb3e05040>.
2017-02-08 16:37:06.495 ClientService2[37948:950374] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7fafb4807a00>.
2017-02-08 16:37:07.288 ClientService2[37948:950374] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'User Pool not registered. The method `setupUserPoolWithId:cognitoIdentityUserPoolAppClientId:cognitoIdentityUserPoolAppClientSecret:region` has to be called once before accessing the shared instance.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102d0fd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010277121e objc_exception_throw + 48
    2   ClientService2                      0x0000000101a213cb +[AWSCognitoUserPoolsSignInProvider sharedInstance] + 171
    3   ClientService2                      0x0000000101a03f65 _TFC14ClientService220SignInViewController18handleCustomSignInfT_T_ + 69
    4   ClientService2                      0x0000000101a04042 _TToFC14ClientService220SignInViewController18handleCustomSignInfT_T_ + 34
    5   UIKit                               0x00000001031358bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x00000001032bbc38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x00000001032bbf51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x00000001032bae4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x00000001031a3545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x00000001031a4c33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x00000001031519ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x000000010393e72d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x0000000103937463 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000102cb4761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000102c9998c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000102c98e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000102c98884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x0000000107268a6f GSEventRunModal + 161
    19  UIKit                               0x0000000103133c68 UIApplicationMain + 159
    20  ClientService2                      0x0000000101a20bbf main + 111
    21  libdyld.dylib                       0x000000010539168d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

1 个答案:

答案 0 :(得分:0)

在创建cognito用户池的实例之前,您应该使用控制台中提供的信息注册您的用户池。此信息是clientId,poolId和clientSecret。之后,您可以正确创建用户池实例。

例如,当应用启动时,您应该执行以下操作:

let poolName = "poolName"

// You should update the region to be the one where you created the pool
let serviceConfiguration = AWSServiceConfiguration(region: AWSRegionType.usWest2, credentialsProvider: nil)

let configuration = AWSCognitoIdentityUserPoolConfiguration(clientId: "Client Id found in the console here", clientSecret: "Client secret found in the console here", poolId: "Pool Id here")

AWSCognitoIdentityUserPool.register(with: serviceConfiguration, userPoolConfiguration: configuration, forKey: poolName)

之后,您可以通过执行以下操作获得对用户池的引用:

let userPool = AWSCognitoIdentityUserPool(forKey: poolName)

所有提到的信息都可以在用户池控制台中找到!