Maduranga E
Maduranga E

Reputation: 1689

How to check if a user is in the XMPPRoster?

my iOS app currently works with the XMPPFramework to for chatting. But I need it to be abel to check if there is user existing in my contact list for a given xmpp username. Any idea on where to look would be appreciated.

Upvotes: 1

Views: 1213

Answers (1)

Jungsu Kim
Jungsu Kim

Reputation: 94

You have to understand how XMPPRoster works in XMPPFramework.

If I send sever to request friend’s list, this structure will be send

<iq id="xxx" type="get">
   <query xmlns="jabber:iq:roster"></query>
</iq>

"iq" means you query to server something and "query" is what you want to receive something.

XMPPRosterMemoryStorage *rosterStorate = [[XMPPRosterMemoryStorage alloc] init];
XMPPRoster * roster = [[XMPPRoster alloc] initWithRosterStorage:rosterStorate];
[roster addDelegate:self delegateQueue:dispatch_get_main_queue()];
[roster activate:[self xmppStream]];
[roster fetchRoster];

If you look at the fetchRoster method, you can find the query what i write above the source code.

And you have to define - (void)xmppRosterDidPopulate:(XMPPRosterMemoryStorage *)sender method in XMPPRosterMemoryStorageDelegate

Good luck to you.

Upvotes: 1

Related Questions