我在AppDelegate.m中实现了以下方法。
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
有人可以告诉我这个方法在哪种情况下被调用,这个方法的目的是什么?
谢谢。
答案 0 :(得分:2)
试试这个以获取名单
-(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`
答案 1 :(得分:1)
这将被调用为任何XMPP查询(XMPPIQ)的响应,如
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:SERVER_DISCO_ITEMS];
XMPPIQ *iq = [XMPPIQ iq];
[iq addAttributeWithName:@"id" stringValue:FETCH_SERVER_DISCO_ID];
[iq addAttributeWithName:@"to" stringValue:serverName];
[iq addAttributeWithName:@"type" stringValue:@"get"];
[iq addChild:query];
[_xmppStream sendElement:iq];
作为对此的回应,您可以通过回复来回复
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
答案 2 :(得分:-1)
例如,当您的朋友从朋友列表中删除您的帐户时,系统会调用此信息。