无法在 XMPP 中获取消息传递回执 [英] Can't get message delivery receipt in XMPP

查看:27
本文介绍了无法在 XMPP 中获取消息传递回执的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 XMPP 的新手.我正在为我的聊天应用程序使用 XMPP 和 Open fire 服务器.该应用程序正在运行,但现在我想获取消息传递回执.我为此使用以下代码,在 setupStream 中:

I am new to XMPP. I'm using XMPP and Open fire server for my chat app. The application is working but now I want to get message delivery receipt. I'm using the following code for that, in setupStream:

   xmppMessageDeliveryRecipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()];
   xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = YES;
   xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = YES;
   [xmppMessageDeliveryRecipts activate:xmppStream];

sendMessage中:

    NSString *messageID=[xmppStream generateUUID];
    NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
    [message addAttributeWithName:@"type" stringValue:@"chat"];
    [message addAttributeWithName:@"id" stringValue:messageID];
    [message addAttributeWithName:@"to" stringValue:myJID];
    [message addChild:body];

但我无法获得消息送达回执.我怎么才能得到它?有人知道吗?

But i can't get message delivery receipt. How can I get it? Anybody knows?

推荐答案

您已经收到交货回执响应,但 XMPPMessageDeliveryReceipts 模块不会自动处理它.您需要存储所有传入和传出的消息(检查XMPPMessageArchiving 模块,它可以将消息保存在XMPPMessageArchiving_CoreDataStorage 实例中),检查消息是否hasReceiptResponse(XMPPMessage+XEP_0184 类别中定义),在接收响应中找到消息 id 并在消息存储中将相应消息标记为已交付"(您可能需要添加新属性,例如已交付"到 XMPPMessageArchivingCoreDataObject(如果你会使用这个模块,或者制作你自己的存储机制)

You are already receiving delivery receipt responses, but XMPPMessageDeliveryReceipts module does not handle it automatically. You need to store all incoming and outgoing messages (check XMPPMessageArchiving module, it can save messages in the XMPPMessageArchiving_CoreDataStorage instance), check if message hasReceiptResponse (defined in XMPPMessage+XEP_0184 category), find the message id in the receipt response and mark corresponding message as "delivered" in the message storage (you may need to add new property e.g. "delivered" to XMPPMessageArchivingCoreDataObject if you will use this module, or make your own storage mechanism)

这篇关于无法在 XMPP 中获取消息传递回执的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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