0

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

MrPk
  • 2,862
  • 2
  • 20
  • 26

1 Answers1

1

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.

dichen
  • 1,643
  • 14
  • 19
  • Thanks for help and my room configure is persistent so i will try to destory room. – shraddha k vaishanani Feb 06 '17 at 03:41
  • [_xmppRoom destroyRoom]; called but not delete/exit group.if possible then please give me steps of delete/exit group. – shraddha k vaishanani Feb 06 '17 at 06:17
  • It was working to me and tested. Read this doc, http://xmpp.org/extensions/xep-0045.html#roomconfig. Make sure only Owner can destroy the room. You can check the xmppStreamDelegate and see if there is any error response back. – dichen Feb 06 '17 at 18:43
  • hello dichen, i tried your code and successfully delete Room but now i need remove particular user from Room. For that i have tried many code but not work. if you have any information or code then please help me. thank you – shraddha k vaishanani Mar 06 '17 at 11:55
  • Could you tell me what have you done to remove a member? Seriously you need to read through the XEP-0045 I mentioned above, here is the tag for modifying members, https://xmpp.org/extensions/xep-0045.html#modifymember. According to the doc, Admin Role (Owner by default is) can modify the member list. Unfortunately XmppFramework doesn't implement this, you need to make up your own iq and send it to server. – dichen Mar 06 '17 at 17:52
  • i used 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:@"put jid which you 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]; – shraddha k vaishanani Mar 07 '17 at 03:46
  • I thought you want to remove the user from member list, right? [item addAttributeWithName:@"affiliation" stringValue:@"member"]; means you are setting the user as `Member`. Have you read https://xmpp.org/extensions/xep-0045.html#modifymember? – dichen Mar 07 '17 at 04:59
  • yes i read but i will make Room Delete functionality same like Whats app.For that i need your help.So if any suggestion then please give me. – shraddha k vaishanani Mar 07 '17 at 06:17
  • I have pointed it out earlier, Admin can modify the member list, what you need to do it take the member out of the member list. See how the doc says, it's well documented I guess maybe you should set the affiliation to 'None' instead of 'member'. Myself never try this functionality, so not positive. – dichen Mar 07 '17 at 06:24
  • currently i developed Group Destroyed functionality and it's working properly but i need exit functionality. For example,i made one Group and invite 3 user and all 3 user join group.After Some time i exit from group that time any one member assign as Group admin.In short Group Exit functionality i will develop. – shraddha k vaishanani Mar 07 '17 at 06:35
  • You mean you want to `Promote a random of rest as Owner` when`current Owner quit the room`? – dichen Mar 07 '17 at 17:36
  • yes dichen you are right.so if any idea or suggestion then please help me. – shraddha k vaishanani Mar 08 '17 at 03:40
  • @DivyaPatel see the other post of you, I added some comments – dichen Mar 08 '17 at 04:27
  • yes i saw your comment and currently i am trying to implement this in code. – shraddha k vaishanani Mar 08 '17 at 04:33
  • hello dichen, are you here?i have one confusion. In IQ tag which value pass in from and to element. i passed current user id in from and group name passed in to. – shraddha k vaishanani Mar 08 '17 at 04:58
  • //random user assign as owner of the group Set IQ NSXMLElement *ownerIQ=[NSXMLElement elementWithName:@"iq"]; [ownerIQ addAttributeWithName:@"from" stringValue:[SharedAppDelegate.xmppStream myJID].full]; [ownerIQ addAttributeWithName:@"to" stringValue:self.strnameofgroup]; [ownerIQ addAttributeWithName:@"id" stringValue:@"member1"]; [ownerIQ addAttributeWithName:@"type" stringValue:@"set"]; – shraddha k vaishanani Mar 08 '17 at 05:20
  • //random user assign as owner of the group Set query NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/muc#admin"]; – shraddha k vaishanani Mar 08 '17 at 05:21
  • //random user assign as owner of the group Set item NSXMLElement *item = [NSXMLElement elementWithName:@"item"]; [item addAttributeWithName:@"affiliation" stringValue:@"owner"]; [item addAttributeWithName:@"jid" stringValue:[NSString stringWithFormat:@"%@@%@",strphonenumber,kSIPDomain]]; [query addChild:item]; [ownerIQ addChild:query]; [SharedAppDelegate.xmppStream sendElement:ownerIQ]; – shraddha k vaishanani Mar 08 '17 at 05:22
  • Note that the userJid in a room should be "roomName@conference.hostName/username", that's different than myJID (username@hostName) – dichen Mar 08 '17 at 05:26
  • now it's proper or not? – shraddha k vaishanani Mar 08 '17 at 05:40
  • I guess no, show me your RoomJID and UserJID individually, removing the %20 encode. – dichen Mar 08 '17 at 05:44
  • RoomJID :- abc new@conference.56.19.114.156 UserJID :- 9190333225566@56.19.114.156 Remove UserJID :- 9190333225566@56.19.114.156 Assign as member JID :- 9190333224466@56.19.114.156 – shraddha k vaishanani Mar 08 '17 at 05:48
  • hello dichen, it's not working :( please share any other code available. i have implement group delete same like whats app. i have create roomconfig_persistentroom. – shraddha k vaishanani Mar 08 '17 at 05:56
  • Sorry, I don't have code in hand. What you want to do has been covered by the document, something must be wrong, but without the full code I can't tell. – dichen Mar 08 '17 at 05:58
  • One thing is you need to promote the other owner before you kick yourself out. – dichen Mar 08 '17 at 05:59
  • i have create roomconfig_persistentroom.so this permission effect when delete Group ? – shraddha k vaishanani Mar 08 '17 at 06:00
  • from: abc new@conference.56.19.114.156/9190333225566, to: abc new@conference.56.19.114.156 – dichen Mar 08 '17 at 06:00
  • Printing description of ownerIQ: Printing description of removeIQ: is it proper? – shraddha k vaishanani Mar 08 '17 at 06:07
  • looks right to me. If not working, try see if there is any message or error comes back in the xmppStream delegates, you should see some error back if it doesn't work. – dichen Mar 08 '17 at 06:09
  • ok i am working on this and if any solution found then inform you.Also you have found any solution for that then please inform me. – shraddha k vaishanani Mar 08 '17 at 06:11
  • Hello dichen, i have found fault.Group member/owner not delete because didreceiveIQ not called when group member/owner delete. – shraddha k vaishanani Mar 08 '17 at 06:37
  • yes, it's working if I am the admin of that group, but if I am not admin for that group and want to remove or exit from the group then how I can do it? – Kaushik Movaliya Mar 27 '17 at 12:15
  • how to exit from room by member ? – Bhadresh Sonani Nov 04 '19 at 05:05