1

I have implemented firebase firechat by following raywenderlick at https://www.raywenderlich.com/122148/firebase-tutorial-real-time-chat

but the issue is it is using Anonymous mode.

My app have obtained 2 firebase uid and when User1 logging and send message, I need to set User2 firebase uid so that both can talk. However, my class implement JSQMessagesViewController swift class and only able to set senderId and senderDisplayName and I don't find variable like recipientId.

The method didPressSendButton too doesn't have anywhere to set the recipient firebaseid.

 override func didPressSendButton(button: UIButton!, withMessageText text: String!, senderId: String!, senderDisplayName: String!, date: NSDate!) {

    let itemRef = messageRef.childByAutoId()

    let messageItem = [
        "text": text,
        "senderId": senderId
    ]

    itemRef.setValue(messageItem)

    JSQSystemSoundPlayer.jsq_playMessageSentSound()

    finishSendingMessage()

    isTyping = false

}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mark Thien
  • 1,108
  • 2
  • 22
  • 35

1 Answers1

0

You can created your own message object and as long as it conforms to the JSQMessageData protocol it will work with the controller. Then add your custom variable to that object. There is an example here. https://stackoverflow.com/a/38884743/5894123

Community
  • 1
  • 1
Dan Leonard
  • 3,325
  • 1
  • 20
  • 32