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 UserStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataUsername and PasswordObject

Sample Response:#

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

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

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 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.

caution

If Block/unblock feature is unavailable for your plan, then it will throw 403 exception

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.

caution

If Block/unblock feature is unavailable for your plan, then it will throw 403 exception

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

Send Feedback#

To send the feedback about MirrorFly.

await SDK.sendFeedback(`TITLE`, 'DESCRIPTION');

Request Params#

StatusDescriptionTypeRequired
TITLETitleStringtrue
DESCRIPTIONDescriptionStringtrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Delete My Account#

To delete your MirrorFly account with the feedback.

await SDK.deleteMyAccount(`REASON`, 'FEEDBACK');

Request Params#

StatusDescriptionTypeRequired
REASONReason for deleting the accountStringtrue
FEEDBACKFeedback for the improvements in the futureStringfalse

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Report User Or Group#

To Report a User or Group by another User.

caution

If Report feature is unavailable for your plan, then it will throw 403 exception

await SDK.reportUserOrGroup(`TO_USER_JID`, `CHAT_TYPE`, `MESSAGE_DATA_OBJECT`);

Request Params#

StatusDescriptionTypeRequired
TO_USER_JIDJID of User/Group to be reportedJID Stringtrue
CHAT_TYPEChat type either User/GroupStringtrue
MESSAGE_DATA_OBJECTMessage data Object that has to reportedObjecttrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Enable/Disable Media Encryption#

To enable/disable the media encryption which was storing in the storage server. By default encryption will be false.

await SDK.setMediaEncryption(`TRUE`);

Request Params#

StatusDescriptionTypeRequired
REASONtrue - enable the media encryption. false - disable the media encryptionBooleantrue

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString