Firebase Swift FEventType.ChildChanged不起作用

时间:2016-04-05 14:44:34

标签: swift firebase

我的结构如下,

  "Messages" : {
"0888a5dc-fe8d-4498-aa69-f9dd1361fe54" : {
  "0888a5dc-fe8d-4498-aa69-f9dd1361fe5451879163-8b35-452b-9872-a8cb4c84a6ce" : {
    "counter" : 3,
    "description" : "Breta",
    "lastMessage" : "B85",
    "lastUser" : "51879163-8b35-452b-9872-a8cb4c84a6ce",
    "messageType" : "txt",
    "sortTimestamp" : -1.459861586060744E9,
    "updatedAction" : 1.45986158606074E9,
    "userId" : "51879163-8b35-452b-9872-a8cb4c84a6ce"
  },
  "0888a5dc-fe8d-4498-aa69-f9dd1361fe547bfe8604-58ad-4d18-a528-601b76dd2206" : {
    "counter" : 1,
    "description" : "Romeo",
    "lastMessage" : "",
    "lastUser" : "0888a5dc-fe8d-4498-aa69-f9dd1361fe54",
    "messageType" : "txt",
    "sortTimestamp" : -1.459527387138615E9,
    "updatedAction" : 1.459527387138613E9,
    "userId" : "7bfe8604-58ad-4d18-a528-601b76dd2206"
  }
}

我有:

var messageRef: Firebase

messageRef = Firebase(url: "\(URL_BASE)").childByAppendingPath("Messages2").childByAppendingPath(userID)

.ChildAdded代码运行良好,即使只是更改,但我也希望在发生更改时通知(例如,对于声音通知)。使用.ChildChanged代码,未检测到更改,我做错了什么?

根据文档:"每次修改子节点时都会触发ChildChanged事件。这包括对子节点后代的任何修改。"

非常感谢任何建议。

messageRef.observeEventType(.ChildAdded, withBlock: { snapshot in

        print(snapshot)
})  //working



override func viewWillAppear(animated: Bool) {

messageRef.observeEventType(.ChildChanged, withBlock: { snapshot in
       print(snapshot)

  })  //not working
} 

0 个答案:

没有答案