List of chat room members

萝らか妹 提交于 2019-12-05 21:20:01

This question is old but I recently encountered this exact issue (xmppRoom:didFetchMembersList: is passed an empty array). In my case the problem was that when users got invited to the room they would have a role of "participant" and an affiliation of "none". The fetchMembersList method in XMPPRoom looks for items with an affiliation of "member".

You can change the affiliation like so:

[xmppRoom editRoomPrivileges:@[[XMPPRoom itemWithAffiliation:@"member" jid:userJID]]];

For details on roles and affiliations, see XEP-0045.

use this method when you invite users.

-[xmppRoom editRoomPrivileges:@[[XMPPRoom itemWithAffiliation:@"member" jid:userJID]]];

After you create xmpproom object and call following delegate method

-(void)xmppRoomDidJoin:(XMPPRoom *)sender{
    [sender fetchMembersList];
}


- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items{
    NSLog(@"print user list=====%@",items);
    for (NSXMLElement *xmlItem in items) {
        NSString *jid = [[xmlItem attributeForName:@"jid"]stringValue];
          NSLog(@"print user jid=====%@",jid);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!