Set/Update User Profile Data

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

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
}

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 FILE

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