2

I am using JSQMessagesViewController and Firebase with Twitter Login. enter image description here

I am able to send text message succesfully by using "didPressSendButton".

now I am tring to send Images. I have One Test image. now when I am tring to send Image with "didPressAccessoryButton" . when This function executes image get converted in base64 and saved in firebase database. but problem is that when I pressed didPressAccessoryButton the blue bubble does not show any image.

Komal Kamble
  • 424
  • 1
  • 8
  • 25
  • This question is super vague. Please see how to construct an awesome question here [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – Jay Apr 30 '16 at 16:16

1 Answers1

2

I take it that by sending a text you use:

    override func didPressSendButton(button: UIButton!, withMessageText text: String!, senderId: String!, senderDisplayName: String!, date: NSDate!)
{
self.sendMessage(text, video: nil, picture: nil)
    self.finishSendingMessage()
}

and that you have a function in the didFinishPickingMediaWithInfo function to save the image in base64 in Firebase, you can use the following code there to have the picture show up in a bubble, that said I combine all in a sendMessage function,but the following should help:

    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
    let picture = info[UIImagePickerControllerEditedImage] as? UIImage

    if (info[UIImagePickerControllerEditedImage] as? UIImage) != nil
    {
        let mediaItem = JSQPhotoMediaItem(image: nil)
        mediaItem.appliesMediaViewMaskAsOutgoing = true
        mediaItem.image = UIImage(data: UIImageJPEGRepresentation(picture, 0.5)!)
        let sendMessage = JSQMessage(senderId: senderId, displayName: self.senderFullName, media: mediaItem)
        self.messages.append(sendMessage)
        self.finishSendingMessage()
    }

    picker.dismissViewControllerAnimated(true, completion: nil)
}

good luck (also you might want to look at not storing large images in Firebase, as it is not recommended)

Peter de Vries
  • 780
  • 1
  • 6
  • 14