【发布时间】:2017-03-17 02:11:54
【问题描述】:
我正在尝试退出 Firebase API,但我似乎不知道如何处理可能发生的任何错误。
Firebase pod 提供了一种退出方法:
FIRAuth.auth()?.signOut()
它标有throws,所以我将它包装在do/try/catch 块中以测试退出过程:
do {
try FIRAuth.auth()?.signOut()
} catch (let error) {
print((error as NSError).code)
}
我看到 signOut 方法在 Firebase pod 中标记为 throws,但我看不到它如何异步处理任何错误。我尝试进入飞行模式,这会在发生网络请求的其他任何地方触发我的代码中的网络错误,但是使用 signOut 方法时,不会捕获该错误,因为我没有要执行的完成处理程序。 Firebase pod 中的所有其他身份验证方法都有一个完成处理程序,我可以在其中处理错误。
以下是 Firebase pod 中 signOut 方法的文档:
/** @fn signOut:
@brief Signs out the current user.
@param error Optionally; if an error occurs, upon return contains an NSError object that
describes the problem; is nil otherwise.
@return @YES when the sign out request was successful. @NO otherwise.
@remarks Possible error codes:
- @c FIRAuthErrorCodeKeychainError Indicates an error occurred when accessing the keychain.
The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary
will contain more information about the error encountered.
*/
open func signOut() throws
当我没有允许我检查错误的完成处理程序时,您对处理用户注销的适当方法有什么建议吗?
【问题讨论】:
标签: swift firebase-authentication