robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

How to read Timestamp from message object? #1201

Open mohdsafadsaal opened 3 years ago

mohdsafadsaal commented 3 years ago

Hi,

I integrated XMPP framework. i was trying to read timestamp from XMPPMessage object.

i tried to get it from message.delayedDeliveryDate and message.delayedDeliveryFrom both are coming nil.

adozenlines commented 3 years ago

Are you using the 203 extension?

https://github.com/robbiehanson/XMPPFramework/tree/master/Extensions/XEP-0203

https://xmpp.org/extensions/xep-0203.html

hamzaozturk commented 3 years ago

You should create your date object as below:

let date = message.delayedDeliveryDate ?? Date()

If a message that is sent to an offline entity and stored for later delivery, then the delayedDeliveryDate will be set. Otherwise, nil. Therefore, you need to use the current date.