I am developing one chat app in that i need to show message status like WhatsApp app for that i have tried XEP-0333(Chat Marker) but facing issue Like.
1) After getting Received Marker from other end XMPPMessage Archive not updated message with Received Marker (In Core data, message chat marker status not updated).
2) How to implement Displayed Marker logic? (means for each message we need to send displayed marker or for only one dialog at once.)
XEP Link : XEP-0333
Code:
//(Sender Part)
let completeMessage = DDXMLElement.element(withName: "message") as! DDXMLElement //(In that i have set id,body,to and type as chat)
let msgObj = XMPPMessage(from: completeMessage)
msgObj?.addMarkableChatMarker()
xmppStream?.send(msgObj)
//(Receiver Part)
didReceivedMessage - Method
//*Check One condition*
if message.isChatMessageWithBody() && message.isErrorMessage() == false {
if (message.hasChatMarker() == true){
printLog("Message ID\(message.elementID())")
let msgElement = XMPPMessageMng.getChatMessageElement(recipient: message.from().bare(), thread: "")
let threadElement = DDXMLElement.element(withName: "thread") as! DDXMLElement
threadElement.stringValue = "Thread"
msgElement.addChild(threadElement)
let msgReceived = XMPPMessage(from: msgElement)
msgReceived?.addReceivedChatMarker(withID: message.elementID())
xmppStream.send(msgReceived)
}
}
else{
if (message.hasMarkableChatMarker() == true){
printLog("Chat Marker ID\(message.chatMarkerID())")
}else if (message.hasReceivedChatMarker() == true){
printLog("Chat Marker ID\(message.chatMarkerID())")
}
}
//For Display Marker I have done below things. - When you load message from message archive with JID. loadArchivedMessagesFromJID - Method
//message as XMPPMessageArchiving_Message_CoreDataObject
let msgReceived = XMPPMessage(from: msgElement)
msgReceived?.addDisplayedChatMarker(withID: message.message.elementID())
xmppStream.send(msgReceived)
Let me know in which right way we can implement Chat marker protocol.
Dev Tools : Xcode 8.3(Swift 3.0) , Server : ejabberd