The contact LID. Only LIDs carry a username.
Skip the local record and query the server
// Cached when available, otherwise queried
const result = await WPP.contact.getUsername('[lid]@lid');
console.log(result.username);
// Always hit the server and refresh the stored value
const result = await WPP.contact.getUsername('[lid]@lid', true);
if (result.usernameChanged) {
console.log(`${result.oldUsername} is now ${result.username}`);
}
Get the username (@username) currently associated with a LID
This is the reverse of queryUsernameExists: it answers "which username does this contact have now?". Use it to refresh a username you displayed earlier, since usernames are mutable while the LID is not.
By default the locally stored username is returned when there is one. Pass
refreshto always query the server, which also updates the local record.