简体   繁体   中英

How to delete or Exit Particular Groupchat using XMPP in iOS

Currently i am making chat application and i required to delete Particular groupchat.

To delete group i tried 2 solutions but are not working.

1st solution i applied as follow :-

xmppRoomStorage = [[XMPPRoomMemoryStorage alloc] init];

XMPPJID *roomJid = [XMPPJID jidWithString:self.strnameofgroup];

_xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomStorage jid:roomJid];

[_xmppRoom removeDelegate:self delegateQueue:dispatch_get_main_queue()];

[_xmppRoom deactivate];

[_xmppRoom leaveRoom];

2nd solution i applied as follow :-

1st fetch all members in the groupchat and then all members left groupchat manually but it also not working.

NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/muc#admin"];

 NSXMLElement *item = [NSXMLElement elementWithName:@"item"];

 [item addAttributeWithName:@"affiliation" stringValue:@"member"];

 [item addAttributeWithName:@"jid" stringValue:@"jid to remove"];

 [query addChild:item];

XMPPIQ *RemoveUser = [[XMPPIQ alloc] initWithType:@"set" to:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@",dialuser2,kSIPDomain]] elementID:@"some random id" child:query];

  [SharedAppDelegate.xmppStream sendElement:RemoveUser];

So please help me if any solution to delete particular group.

Thank you

What's the configure of your room? Is it a persistent room?

If yes, then the room must be destroyed by the owner.

xmppRoom.destroyRoom()

Otherwise, the room will be automatically deleted if all the members left.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM