I had the same problem, I got queryElement as nil . I changed the response code to see the XML as follows:
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { //DDLogVerbose(@"%@: %@ - %@", THIS_FILE, THIS_METHOD, [iq elementID]); //NSXMLElement *queryElement = [iq elementForName:@"query" xmlns: @"http://jabber.org/protocol/disco#items"]; NSXMLElement *queryElement = [iq elementForName:@"query" xmlns: @"jabber:iq:roster"]; NSLog(@"IQ: %@",iq); if (queryElement) { NSArray *itemElements = [queryElement elementsForName: @"item"]; NSMutableArray *mArray = [[NSMutableArray alloc] init]; for (int i=0; i<[itemElements count]; i++) { NSString *jid=[[[itemElements objectAtIndex:i] attributeForName:@"jid"] stringValue]; NSLog(@"%@",jid); [mArray addObject:jid]; } } return NO; }
As you can see what I changed, this is xmlns: from this xmlns: @"http://jabber.org/protocol/disco#items" to this xmlns: @"jabber:iq:roster" and it gave me a list users.
I am using ejabberd, not sure if this works for all other XMPP servers.
I also found that this gave me a list of "buddy" users, it seems if you want all the "users" you had to make an administrator request. For more information see this link: https://www.ejabberd.im/node/3420
source share