Profile

Profile related methods are described here.

Register#

To register a new user use the below method. You will get the username and password in the response. By providing that username and password to the connect method you can connect in to the server further.

note

During the initialization, if the isTrialLicenseKey is set to true in the initialization, users will be registered in the trial mode.

await SDK.register(`USER_IDENTIFIER`);

Request Params#

StatusDescriptionTypeRequired
USER_IDENTIFIERUnique Id to Register the User. We accept only the AlphaNumeric StringStringtrue

Request Input for registerMetaData#

ArgumentsDescriptionType
keyName of the KeyString
valueName of the valueString or Boolean or Number

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataUsername, Password, isProfileUpdated, isSandbox, userJidObject

Sample Response:#

{
statusCode: 200,
message: "Success",
data: {
username: "123456789",
password: "987654321",
isProfileUpdated: true,
isSandbox: true,
userJid: "1234567890@xmppdomain"
}
}

Connect with Username#

Make a connection to the server by using the credentials got as a response of the register method. Once the connection is made successfully, it returns a Promise with statusCode of 200, else throws an Error.

This will also emit the connection status. It will be received in connectionListener callback function. If any error occurs while making a connection with the server, You will receive the error in the callback.

await SDK.connect(`USERNAME`, `PASSWORD`);

Request Params#

StatusDescriptionTypeRequired
USERNAMEUsernameStringtrue
PASSWORDPasswordStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Sample Response:#

{
message: "Login Success",
statusCode: 200
}

Logout#

To disconnect the XMPP connection, use the below method.

await SDK.logout();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Get User Profile Detail#

To get the Profile detail of the user, send a request as described below.

await SDK.getUserProfile(`TO_USER_JID`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataProfile Details ObjectObject

Check here for response format.

note

userprofilelistener also will be triggered with the same response.

Update User Profile Detail#

To set the Profile detail of the user, send a request as described below.

Once the request is successfully made, a callback userProfileListener will be triggered for the current user and also for the friends (Contacts of the current user) to get the latest profile details.

const IMAGE = {
extension: '',//Image Format
fileSize: '',//number File Size
filename: '',//Image FileName
height: '',//number Height
modificationTimestamp: '',// number modificationTimestamp
replyTo: '',//Optioinal
type: ''//Image Type
uri: '',//Image Uri
width: '' //number Width
}
await SDK.setUserProfile(`NAME`, IMAGE, `STATUS`, `MOBILE_NUMBER`, `EMAIL`);

Request Params#

StatusDescriptionTypeRequired
NAMENickname of the UserStringtrue
IMAGEProfile Image - Upload an image file or image URLObject / Stringtrue
STATUSProfile StatusStringtrue
MOBILE_NUMBERMobile NumberStringtrue
EMAILEmail AddressStringtrue

Example Request#

Image as a URL

await SDK.setUserProfile(
"Name",
"https://domain/path/image.png",
"status",
"1111111111",
"email@domain",
);

Image as a IMAGE

await SDK.setUserProfile("Name", IMAGE, "status", "1111111111", "email@domain");

Get User's Last Seen Time#

To get the user's last seen, send a request as described below.

await SDK.getLastSeen(`TO_USER_JID`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataLast Seen Details ObjectObject

Get Current User Jid#

To get the Jid of the logged in user.

await SDK.getCurrentUserJid();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
userJidJID of the UserJID String