func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String:Any]){
let imgTemp = info[UIImagePickerControllerOriginalImage] as? UIImage// get image from imagePickerViewController
print("This is the Pic Info *** \(String(describing: imgTemp))")
XmppManager.sharedInstance.sendImageMessage(toUser: (currentChats?.nameUser!)!, imageToUser: imgTemp?.images)
if imgTemp != nil {
let message = MessageShared()
message.isOwnner = true
message.messages = ""
message.userImageUrl = imgTemp as? UIImage
currentChats?.message.append(message)
textMessageView.text = ""
}
tableView.reloadData()
imagePicker.dismiss(animated: true, completion: nil)
}
the send function
func sendImageMessage(toUser jid:String, imageToUser Image:UIImage) -> () {
let dataFile = UIImagePNGRepresentation(Image)
let imgStr = dataFile?.base64EncodedString()
let body = DDXMLElement.element(withName: "body") as! DDXMLElement
let imageAttachement = DDXMLElement.element(withName: "attachment", stringValue: imgStr!) as! DDXMLElement
let messageID = self.xmppStream?.generateUUID
body.stringValue = "Upload Image"
let completeMessage = DDXMLElement.element(withName: "message") as! DDXMLElement
completeMessage.addAttribute(withName: "id", stringValue: messageID!)
completeMessage.addAttribute(withName: "type", stringValue: "chat")
completeMessage.addAttribute(withName: "to", stringValue: jid)
completeMessage.addChild(body)
completeMessage.addChild(imageAttachement)
let active = DDXMLElement.element(withName: "active", stringValue:
"http://jabber.org/protocol/disco#items") as! DDXMLElement
completeMessage.addChild(active)
self.xmppStream?.send(completeMessage)
}
thanks...
self.xmppOutOfBandMessaging.submitOutgoingMessage(msg, withOutOfBandData: data, mimeType: messageModel.mimeType)
You can get acknowledgment of media message by its delegate methods of XMPPOutOfBandMessaging class.
hi,You can use XEP-0066 extension XMPPOutOfBandMessaging class for send media messgage. it can be image, audio or video.
self.xmppOutOfBandMessaging.submitOutgoingMessage(msg, withOutOfBandData: data, mimeType: messageModel.mimeType)
You can get acknowledgment of media message by its delegate methods of XMPPOutOfBandMessaging class.
Hi,
func xmppOutOfBandResourceMessaging(_ xmppOutOfBandResourceMessaging: XMPPOutOfBandResourceMessaging, didReceiveOutOfBandResourceMessage message: XMPPMessage) {
print("we recieved something from XMPPOUTOFBAnd")
self.xmppOutOfBandMessaging.submitOutgoingMessage(msg, withOutOfBandData: data, mimeType: messageModel.mimeType)
really I need help I could not find somebody that implemented using this class so I need to see some thing if you do not mind in swift.
I tried to add it in the imagePickerController but it was not predefined.
Thanks in advance
var xmppOutOfBandMessaging: XMPPOutOfBandMessaging
var xmppOutOfBandMessagingStorage: XMPPOutOfBandMessagingFilesystemStorage
but I get an error (Use of undeclared type 'XMPPOutOfBandMessaging')
I just can add -> var xmppOutofBandData = XMPPOutOfBandResourceMessaging()