tobeiosdev tobeiosdev - 1 year ago 81
Swift Question

onDisconnectRemoveValue doesn't delete (key: value) after log out firebase?

I am using

try! FIRAuth.auth()!.signOut()
for log out account in Swift. But
doesn't remove (key: true) from Firebase "online/key" child node. Should I remove this key manually or what's wrong with this case?

Answer Source

If you CMD+CLICK on onDisconnectRemoveValue you will be navigated to the firebase documentation , :-

  • Ensure the data at this location is removed when
    • the client is disconnected (due to closing the app, navigating to a new page, or network issues).

So when you log out the user the network link to firebase is still alive, you haven't closed your app yet and neither have you navigated to another app leaving your firebase app in background.

So, try using this:-

FIRDatabase.database().reference().child("your_Path").updateChildValues(["online" : false], withCompletionBlock: {(err, ref) in

        if err == nil{

            // Sign out your user

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download