【发布时间】:2014-12-30 15:55:27
【问题描述】:
我正在使用适用于 iOS 的 XMPPFramework,我需要显示消息的日期和时间。
经过一番搜索,我认为我应该使用XMPPAutoTime 模块,但我没有找到一些示例。
我在流设置中使用过:
xmppAutoTime = [[XMPPAutoTime alloc] initWithDispatchQueue:dispatch_get_main_queue()];
[xmppAutoTime activate:self.xmppStream];
我的发送消息方法如下:
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:to];
[message addChild:[XMPPTime timeElement]];
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:text];
[message addChild:body];
我的 XML 看起来像:
<message type="chat" to="toJID">
<time xmlns="urn:xmpp:time">
<tzo>+03:00</tzo>
<utc>2014-12-30T15:24:22Z</utc>
</time>
<body>message text</body>
</message>
所以你可以看到我有时间,这是正确的。问题是我如何将它用于XMPPMessage
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
【问题讨论】:
标签: ios xmpp xmppframework