我正在iPhone中开发一个群聊应用程序,我想在其中实现此功能:管理员可以删除/踢任何参与者。参与者必须收到管理员已将他从该组中删除的通知。
我尝试过以下代码,但没有成功:
XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"];
[presence addAttributeWithName:@"from" stringValue:[[DatingUserDefaults sharedDefaults] getGroupName]];
[presence addAttributeWithName:@"to" stringValue:[[DatingUserDefaults sharedDefaults] getUsername]];
[xmppStream sendElement:presence];
我在Google上搜索过,并且知道我必须在Objective-C中生成以下格式:
<presence
from='harfleur@chat.shakespeare.lit/pistol'
to='pistol@shakespeare.lit/harfleur'
type='unavailable'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='none' role='none'>
<actor nick='Fluellen'/>
<reason>Avaunt, you cullion!</reason>
</item>
<status code='307'/>
</x>
</presence>
有没有人知道如何做到这一点?
答案 0 :(得分:1)
这适合我。
<iq type="set" to="roomid" id="some random no"><query xmlns="http://jabber.org/protocol/muc#admin"><item affiliation="none" jid="jid you want to remove"></item></query></iq>
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/muc#admin"];
NSXMLElement *item = [NSXMLElement elementWithName:@"item"];
[item addAttributeWithName:@"affiliation" stringValue:@"none"];
[item addAttributeWithName:@"jid" stringValue:"jid to remove"];
[query addChild:item]; XMPPIQ *RemoveUser = [[XMPPIQ alloc] initWithType:@"set" to:[XMPPJID jidWithString:roomid] elementID:@"some random id" child:query ];
[self.xmppStream sendElement:RemoveUser];
答案 1 :(得分:0)
这项工作对我来说
[self.xmppRoom leaveRoom];