Iphone iOS离开群聊用户
我正在iPhone上开发一个群组聊天应用程序,我想在其中实现这个功能:管理员可以删除/踢任何参与者。参与者必须收到管理员已将其从该组中删除的通知 我尝试了以下代码,但没有成功:Iphone iOS离开群聊用户,iphone,xmpp,Iphone,Xmpp,我正在iPhone上开发一个群组聊天应用程序,我想在其中实现这个功能:管理员可以删除/踢任何参与者。参与者必须收到管理员已将其从该组中删除的通知 我尝试了以下代码,但没有成功: XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"]; [presence addAttributeWithName:@"from" stringValue:[[DatingUserDefaults sharedDefaults]
XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"];
[presence addAttributeWithName:@"from" stringValue:[[DatingUserDefaults sharedDefaults] getGroupName]];
[presence addAttributeWithName:@"to" stringValue:[[DatingUserDefaults sharedDefaults] getUsername]];
[xmppStream sendElement:presence];
我在谷歌上搜索过,知道我必须用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>
阿凡特,你这个被淘汰的人!
有人知道怎么做吗?这对我很有用
<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];
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”];
[查询添加子项:项];XMPPIQ*RemoveUser=[[XMPPIQ alloc]initWithType:@“设置”为:[XMPPJID jidWithString:roomid]elementID:@“某个随机id”子项:查询];
[self.xmppStream sendElement:RemoveUser];
这是我的工作
[self.xmppRoom leaveRoom];
是的,它的工作,如果我是该组的管理员,但如果我不是该组的管理员,并希望删除或退出该组,那么有什么建议?你有任何解决方案吗?我也面临同样的问题。