我在Xcode 8中使用Swift 3,我在我的代码中获得了这个门。有什么办法可以解决吗?如果有人能提供帮助,我感激不尽。
FIRAuth.auth()?.signIn(with: credential, completion: {(user: FIRUser?, error: NSError?) in
if error != nil {
print(error!.localizedDescription)
return
}else {
print(user?.email)
print(user?.displayName)
错误:
无法转换类型的值'(FIRUser?,NSError?) - > ()'到期望的参数类型'FIRAuthResultCallback?'
答案 0 :(得分:0)
您的完成块需要返回值的变量名称(用户对象和错误)在下面的示例中,我为用户对象添加了名称“user”,并为错误对象添加了错误。
FIRAuth.auth()?.signIn(with: credential, completion: {(user, error) in
if error != nil {
print(error!.localizedDescription)
return
}else {
print(user?.email)
print(user?.displayName)
答案 1 :(得分:0)
实际上,在Xcode 8中,有时我们会遇到打开完成块的问题。在您的代码中,块无法正常打开。你的街区应该打开:
FIRAuth.auth()?.signIn(with: credential , completion: { (user, error) in
//Do as per your need here
})
希望,这有帮助
答案 2 :(得分:0)
确保您不会复制代码中的FIRAuth.auth()?.signIn
。当我把它放在SignInViewController类下面时,我遇到了错误。
这是iOS Google Sign的工作代码我在最新的 Swift 4 中尝试过。
FIRAuth.auth()?.signIn(with: credential, completion: { (user: FIRUser?, error: Error?) in
if error != nil {
print(error!.localizedDescription)
return
} else {
print(user?.email)
print(user?.displayName)