【问题标题】:Need assistance regarding using the xep-0184需要有关使用 xep-0184 的帮助
【发布时间】:2012-07-20 09:59:40
【问题描述】:

我正在为我当前的项目使用robbiehanson/XMPPFramework,我可以向我名册中的人发送和接收消息,但现在我必须实现消息传递状态。我知道 xep 它的 0184 并且我也包含在我的项目中,我很难使用它。

我在xep-0184 document 中读到请求元素也必须包含在消息中,所以这是我的代码:

#import "XMPPMessage+XEP_0184.h"
.
.
.
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];

[body setStringValue:messageStr];

NSXMLElement *request = [NSXMLElement elementWithName:@"request" xmlns:@"urn:xmpp:receipts"];

NSXMLElement *message = [NSXMLElement elementWithName:@"message"];

[message addAttributeWithName:@"type" stringValue:@"chat"];

[message addAttributeWithName:@"to" stringValue:[defaults objectForKey:@"chatWith"]]; 
[message addChild:body];
[message addChild:request];
.
.
.
XMPPMessage *xm = [[XMPPMessage alloc]init];
NSLog(@"..1..%d",[xm hasReceiptRequest]);        // Result = 0
NSLog(@"..2..%d",[xm hasReceiptResponse]);       // Result = 0
NSLog(@"..3..%@",[xm extractReceiptResponseID]); // Result = (null)
NSLog(@"..4..%@",[xm generateReceiptResponse]);  // Result = <message><received xmlns="urn:xmpp:receipts"></received></message>

请帮助我如何获取消息传递状态。

【问题讨论】:

标签: objective-c ios xmpp xmppframework


【解决方案1】:

我想你忘了添加模块本身。 当你想添加一个像 XMPPMessageDeliveryReceipts 这样的 XMPPModule 时,你应该先把它添加到 XMPPStream 对象中,然后你才能使用它的功能。

执行以下操作:

// Setup Message Delivery Recipts Object
XMPPMessageDeliveryReceipts* xmppMessageDeliveryRecipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()];
xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = YES;
xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = YES;

[xmppMessageDeliveryRecipts activate:xmppStream];

当 xmppStream 是您的主要 XMPPFramework 对象时。

希望我能帮上忙。

【讨论】:

  • 你能详细解释一下吗?因为即使我们通过 XMPP Stream 实现了传递通知,我们也无法接收到任何通知。请分享有关交货通知的更多信息
  • 嘿,看看这里 - stackoverflow.com/questions/20852336/… 它可能对你有更多帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-06-23
  • 2014-12-26
  • 2013-08-12
  • 2014-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多