Ios 如何发送自定义XMPPPresence节

Ios 如何发送自定义XMPPPresence节,ios,xmpp,offline,Ios,Xmpp,Offline,我正在开发聊天应用程序。我想添加上次看到的功能。所以它认为可以通过发送带有“XMPPPresence”的自定义数据来实现,所以我尝试了以下代码: 当用户“goOffline”时,我将在下面的小节中发送 XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"]; NSXMLElement *show = [NSXMLElement elementWithName:@"show" stringValue:@"awa

我正在开发聊天应用程序。我想添加上次看到的功能。所以它认为可以通过发送带有“XMPPPresence”的自定义数据来实现,所以我尝试了以下代码:

当用户“goOffline”时,我将在下面的小节中发送

XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"];
NSXMLElement *show = [NSXMLElement elementWithName:@"show" stringValue:@"away"];

NSXMLElement *status = [NSXMLElement elementWithName:@"status" stringValue:@"away"];

[presence addChild:show];
[presence addChild:status];

[[self xmppStream] sendElement:presence];
调试时,我检查发送的值是否正确:

<presence type="unavailable"><show>away</show><status>away</status><x xmlns="vcard-temp:x:update"><photo/></x></presence>
但我得到的结果如下:

<presence xmlns="jabber:client" from="user1@myserver.com/3015805338140183012566044" to="user2@myserver.com/183258723140182997445059" type="unavailable"></presence>


这完全奇怪,因为它应该是可用的。

您使用的是哪台XMPP服务器

如果您使用的是明火,请发送以下小节:

XMPPPresence*presence=[XMPPPresence];//type=“available”是隐式的
如果您正在使用google或其他第三方服务器,则需要在流中发送以下小节:

XMPPPresence*presence=[XMPPPresence];//type=“available”是隐式的
NSXMLElement*优先级=[NSXMLElement elementWithName:@“priority”stringValue:@“24”];[儿童:优先权];
[流发送元素:存在]

此代码将使用户在线,所有其他花名册将获得有关发件人状态的更新。

我只在离线状态下面临问题,我无法获得离线操作时发送的确切格式。更多关于我使用Ejabbered进行脱机的信息,请使用以下代码:XMPPPresence*presence=[XMPPPresence presence-withtype:@“unavailable”];[流发送元素:存在];如果它对你有效,那么请不要忘记给答案打分。先生,它已经起作用了,请仔细阅读我的问题。我想发送状态并显示带有“不可用”标签的标签。如何做到这一点?您是否尝试过以下操作:[状态添加属性名称:@“状态”字符串值:@“您的自定义邮件”];
    XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit
[[self xmppStream] sendElement:presence];
<presence xmlns="jabber:client" from="user1@myserver.com/3015805338140183012566044" to="user2@myserver.com/183258723140182997445059" type="unavailable"></presence>