How to Kick the User or Member from XMPPRoom

584 views Asked by At

I implemented the following code for kicking the user from XMPPRoom. I used XMPPFramework. See below code

NSXMLElement *destroy = [NSXMLElement elementWithName:@"iq"];
    [destroy addAttributeWithName:@"type" stringValue:@"set"];
    [destroy addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@",[_dictionaryStadium objectForKey:@"RoomID"]]];//stadium nam
    [destroy addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@@%@",@"+923425623868",kXMPPHost]]; // user number.

NSXMLElement *reason = [NSXMLElement elementWithName:@"reason" stringValue:@"leave"];

NSXMLElement *item = [NSXMLElement elementWithName:@"item"];
[item addAttributeWithName:@"role" stringValue:@"none"];
[item addAttributeWithName:@"nick" stringValue:@"nawazish2"]; // usernickname

[item addChild:reason];

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


[query addChild:item];

[destroy addChild:query];


[kKXMPPManager.xmppStream sendElement:destroy];
[kKXMPPManager.xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

When sending a request I received an error. But I received an error, Ex: service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>.

Below are my sending and receiving request through XMPP.

Sending Request:

SEND: <iq type="set" from="[email protected]" to="[email protected]"><query xmlns="http://jabber.org/protocol/muc#admin"><item role="none" nick="nawazish2"><reason>leave</reason></item></query></iq>

Received Request:

RECV: <iq xmlns="jabber:client" type="error" from="[email protected]" to="[email protected]/b228fc86"><query xmlns="http://jabber.org/protocol/muc#admin"><item role="none" nick="nawazish2"><reason>leave</reason></item></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

Please let me know how can I solve the issues of kick user. I searched so many articles and implement those but all in vein.

Thanks

0

There are 0 answers