gpt4 book ai didi

ios - XMPPFramework "typing.."消息状态

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:05 27 4
gpt4 key购买 nike

我正在为我当前的项目使用 robbiehanson/XMPPFramework。如何使用 XMPPFramework 获取消息输入状态?有 XEP-184 协议(protocol),但现在已弃用。在此处需要帮助以获取 iOS 中的撰写状态。问候,巴特

最佳答案

首先导入:

#import "XMPPMessage+XEP_0085.h"

然后根据您的目的添加以下方法。

作曲......

- (void)sendComposingChatToUser:(XMPPJID*)jid {
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
XMPPMessage *xmppMessage = [XMPPMessage messageFromElement:message];
[xmppMessage addComposingChatState];
[xmppStream sendElement:message];
}

主动.....

- (void)sendActiveChatToUser:(XMPPJID*)jid {
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
XMPPMessage *xmppMessage = [XMPPMessage messageFromElement:message];
[xmppMessage addActiveChatState];
[xmppStream sendElement:message];
}

无效...

- (void)sendInactiveChatToUser:(XMPPJID*)jid {
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
XMPPMessage *xmppMessage = [XMPPMessage messageFromElement:message];
[xmppMessage addInactiveChatState];
[xmppStream sendElement:message];
}

走了...

- (void)sendExitChatToUser:(XMPPJID*)jid {
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
XMPPMessage *xmppMessage = [XMPPMessage messageFromElement:message];
[xmppMessage addGoneChatState];
[xmppStream sendElement:xmppMessage];
}

暂停...

- (void)sendPausedChatToUser:(XMPPJID*)jid {
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
XMPPMessage *xmppMessage = [XMPPMessage messageFromElement:message];
[xmppMessage addPausedChatState];
[xmppStream sendElement:message];
}

那么您应该在 appdelgate 中编写以下代码。 (didReceiveMessage) 方法。

例如:

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message{
if ([message isChatMessageWithBody]){
}
else{
if([message elementForName:@"composing"] != nil){



} else if ([message elementForName:@"paused"] != nil) {



} else if ([message elementForName:@"gone"] || [message elementForName:@"inactive"] ) {


}
}

关于ios - XMPPFramework "typing.."消息状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25041025/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com