Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. // chats contain meta information about the chat like last message and count of unread messages
  2.  
  3. let chatRef = ref.child("chats").child(receiverId).child(chatId)
  4. chatRef.observeSingleEventOfType(.Value, withBlock: { (snapshot) -> Void in
  5.  
  6. if !snapshot.exists() {
  7. print("snapshot eists")
  8. // the other side has deleted the chat
  9. // now delete all messages and member objects
  10.  
  11. ref.child("messages").child(chatId).setValue(nil)
  12. ref.child("members").child(chatId).setValue(nil)
  13. } else {
  14. print("snapshot does not exist")
  15. }
  16. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement