2017-01-04 56 views
0

您好使用AWS移动中心在iOS我跟随介绍aut与认证。它说我必须从示例中导入用户池文件。我这样做了,但是,这将引发我一个错误:AWS iOS Swift 3 Cognito类型不符合协议

extension SignInViewController: AWSCognitoIdentityPasswordAuthentication { 

    func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AnyObject>) { 
     self.passwordAuthenticationCompletion = passwordAuthenticationCompletionSource 
    } 

    func didCompleteStepWithError(_ error: Error?) { 
     if let error = error { 
      DispatchQueue.main.async(execute: { 
       UIAlertView(title: "ERROR", 
        message: error.localizedDescription, 
        delegate: nil, 
        cancelButtonTitle: "Ok").show() 
      }) 
     } 
    } 
} 

错误:

Type 'SignInViewController' does not conform to protocol 'AWSCognitoIdentityPasswordAuthentication'

另外:

Protocol requires function 'getDetails(_:passwordAuthenticationCompletionSource:)' with type '(AWSCognitoIdentityPasswordAuthenticationInput, AWSTaskCompletionSource) -> Void'; do you want to add a stub? (AWSCognitoIdentityProvider.AWSCognitoIdentityPasswordAuthentication)

和:

Candidate has non-matching type '(AWSCognitoIdentityPasswordAuthenticationInput, AWSTaskCompletionSource) ->()'

回答

1

按照docs,任何符合的课程应该执行:

– getPasswordAuthenticationDetails:passwordAuthenticationCompletionSource 
– didCompletePasswordAuthenticationStepWithError 

你不实现它们,因此错误。

编辑 是的,你说得对,在斯威夫特3改变函数签名(见here)。

他们应该是这样的:

func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>) 
func didCompleteStepWithError(_ error: Error?) 

看起来你的第一FUNC的版本略有不同。

+0

它们实现了,只是在Swift 3中重命名 –

+0

我参与了并添加了更多的错误信息 –

相关问题