需要有关使用 xep-0184 的帮助 [英] Need assistance regarding using the xep-0184

查看:22
本文介绍了需要有关使用 xep-0184 的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using robbiehanson/XMPPFramework for my current project, I can send and receive messages to people in my roster, but now I have to implement message delivery status. I know the xep its 0184 and I have also included in my project, I am having difficulty utilizing it.

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

I read in xep-0184 document that request element must also included in message, so here is my code:

#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>

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

Please help how do i get a message delivery status.

推荐答案

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

I think you forgot to add the module itself. When you want to add an XMPPModule like XMPPMessageDeliveryReceipts you should add it to the XMPPStream object first, then you can use its functions.

执行以下操作:

// 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 对象时.

When xmppStream is your main XMPPFramework object.

希望我有所帮助.

这篇关于需要有关使用 xep-0184 的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆