使用斯威夫特3

使用斯威夫特3

问题描述:

我想按钮点击这个方法阅读JSQMessagesViewController未读消息,但没有得到结果:使用斯威夫特3

@IBAction func childAdded(_ sender: Any) {  
    let ref = Constants.refs.databaseChats.childByAutoId() 

    ref.observe(DataEventType.childAdded , with: { (snapshot) in 
     let msgData = snapshot.value as? NSDictionary 
     let msg = msgData?["status"] as? String 

     if msg == "sent" { 
      let prntRef = Constants.refs.databaseChats.child("chats").child(ref.key) 
      prntRef.updateChildValues(["status":"Read"]) 
      print("Message Read") 
     } 
    }) { (e) in 
     print(e.localizedDescription) 
    } 
} 
+0

我真的很困惑?我真的不明白你问的是什么问题。我也没有看到标题和提供的代码之间有很多关联。我是否也正确地假设你正在使用'firebase'。你介意提出一个问题,以便我们确定最好的方法来帮助你吗? –

+0

我想添加firebaseChat App消息的功能阅读未读 –

+0

如果发件人发送消息给接收者当接收者阅读消息时显示任何activityIndi​​cator给发件人 –

有这样做的几种方法,有些还比其他的优势。一种解决方案是在firebase中存储像lasReadVariable之类的变量。这是user1的最后一条读取消息,则每次打开chatView时,都会更新该线程上最后一条读取消息的lasReadVariable。在lasReadVariable的对话中为用户2设置observer,并相应地更新messageState

让我知道是否有更多的澄清,我可以给。