2
votes

In Openfire users are created with a "Username" (which is used as the basis for the JID) and a descriptive "Name". How does one retrieve the Name for a given JID in XMPP? I'm using XMPPFramework.

2

2 Answers

1
votes

You may retrieve a user's Display Name using his JID from XMPPUserCoreDataStorageObject like this:

XMPPJID *userJID = @"shakespeare";

XMPPUserCoreDataStorageObject *user = [[[self appDelegate] xmppRosterStorage]
                                           userForJID:userJID
                                           xmppStream:[[self appDelegate] xmppStream]
                                 managedObjectContext:[[self appDelegate] managedObjectContext_roster]];

NSString *userDisplayName = user.displayName;
0
votes

Are you using the CoreData portion of the roster when setting up the XMPPFramework? You can get the user via the JID from the storage class that is set (for example, the XMPPRosterCoreDataStorage).

From here, you can get the user stored from the roster request via the storage class such as:

[xmppStorage userForJID:jid ...]

and from here, the resulting object (XMPPUserCoreDataStorageObject) has fields for 'nickname', 'displayName', etc. Some information can also be obtained from the associated vCard for that JID.