Profile module

Profile related methods are described here.

Register#

To register a new user use the below method.

If autoLogin is true, after successful registration, the user will be logged in with XMPP.

Note: If the sandbox mode is set to true in the initialization, users will be registered in the sandbox mode

await SDK.register(`USER_IDENTIFIER`, `AUTO_LOGIN`);

Request Params#

StatusDescriptionTypeRequired
USER_IDENTIFIERUnique Id to Register the UserStringtrue
AUTO_LOGINAuto Login after RegistrationBooleanfalse

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataUsername and PasswordObject

Sample Response:#

If autoLogin is true

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

If autoLogin is false

{
statusCode: 200,
message: "Success",
data: {
username: "123456789",
password: "987654321"
}
}

Login with Username#

Make a connection by login into the XMPP server using the credentials. 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.login(`USERNAME`, `PASSWORD`);

Request Params#

StatusDescriptionTypeRequired
USERNAMEUsernameStringtrue
PASSWORDPasswordStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Login with QR Code#

If login needs to be done via QR Code scan from Mobile, generate new QR Code with below method.

Once the QR Code scanned successfully, the user will be with XMPP, and username and password will be received in callback response

await SDK.generateQrCode(`DOM_ELEMENT_ID`, `LOGO_ELEMENT_ID`, `SIGNAL_SERVER_URL`, () => {
// Handle Callback Here
});

Request Params#

StatusDescriptionTypeRequired
DOM_ELEMENT_IDCanvas element id in which QR Code has to appendedStringtrue
LOGO_ELEMENT_IDBranding Logo in the QR CodeStringtrue
SIGNAL_SERVER_URLSignal Server URL for Socket ConnectionStringtrue

Example Request#

SDK.generateQrCode(
document.getElementById("canvas"),
document.getElementById("logo"),
"wss://domain.com",
(response) => {
// Handle Response
}
);

Logout#

To disconnect the XMPP connection, use the below method.

await SDK.logout();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Get Friends List#

To get the friends list, send a request as described below.

await SDK.getFriendsList();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataArray of Users ObjectArray

Check here for response format

Note: friendsListListener also will be triggered with the same response.

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.

await SDK.setUserProfile(`NAME`, `IMAGE`, `STATUS`, `MOBILE_NUMBER`, `EMAIL`);

Request Params#

StatusDescriptionTypeRequired
NAMENickname of the UserStringtrue
IMAGEProfile Image - Upload an image file or image URLFile / 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", FILE, "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

Check here for response format.

Block User#

Block User method uses to block the User from sending a message to us, it also hides our information from them. Use the below method by passing the JID of the user whom we are blocking.

await SDK.blockUser(`TO_USER_JID`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue

Unblock User#

To unblock the User use the below method.

await SDK.unblockUser(`TO_USER_JID`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue

Get Users I Blocked#

To get the list of Users whom we blocked, send a request as described below.

await SDK.getUsersIBlocked();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataBlocked User ListArray

Check here for response format.

Get Users Who Blocked Me#

To get the list of Users who blocked Us, send a request as described below.

await SDK.getUsersWhoBlockedMe();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataBlocked User ListArray

Check here for response format.

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

Get User Token#

Generates and retrives new usertoken to access the API.

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

Request Params#

StatusDescriptionTypeRequired
USERNAMEUsernameStringtrue
PASSWORDPasswordStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
userTokenUser TokenString

Set User Token#

To set the user token locally.

await SDK.setUserToken(`TOKEN`);

Request Params#

StatusDescriptionTypeRequired
TOKENUser TokenStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString