我在AppDelegate.m中实现了以下方法。
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
有人可以告诉我在什么情况下调用此方法,此方法的目的是什么?
谢谢。
最佳答案
试试这个以获得名单
-(void)fetchRosterListWithUserId:(NSString *)userId // yourID
{
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"jabber:iq:roster"];
XMPPIQ *iq = [XMPPIQ iq];
[iq addAttributeWithName:@"id" stringValue:FETCH_ROSTER_DISCO_ID];
[iq addAttributeWithName:@"to" stringValue:userId];
[iq addAttributeWithName:@"type" stringValue:@"get"];
[iq addChild:query];
[_xmppStream sendElement:iq];
}
您可以返回响应
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq`