在 Swift 4 中退出 Firebase

Sign Out of Firebase in Swift 4

我想在使用 firebase 登录后退出我的应用程序,我在我的应用程序中尝试了这段代码,但它不起作用。

print("clickSignOut")
        do {
            try Auth.auth().signOut()
       } catch {
         print("can't signOut")strong text
       }
      print(Auth.auth().currentUser ?? "no user")

检查这是否有帮助:

try! Auth.auth().signOut()

这对我总是有效:

do {
    try Auth.auth().signOut()
} catch let error {
    print("Error: ", error.localizedDescription)
}

如果这对您不起作用,请向我们提供更多背景信息。 "it's not working" 是什么意思?如果您使用提供的此代码,它会告诉您遇到什么错误。