Profile module

Get User profile data#

To get the profile data of a user(not a group) call the below method.

ContactManager.getUserProfile(USER_JID,FETCH_FROM_SERVER,SAVE_AS_FRIEND,(isSuccess, throwable, data) -> {
if (success){
val profileData = (ProfileDetails) data["data"]
}else {
// get profile failed print throwable to find the details
}
});

Refer this doc to know more about Profile Class

ArgumentTypeDescription
USER_JIDStringJid of the user
FETCH_FROM_SERVERbooleantrue to fetch from server
SAVE_AS_FRIENDbooleanif true the user will be saved as friend and will be available in contact list
CALLBACKFlyCallbackFlyCallback implemented as as lambda expression

Update User profile#

To update your profile call the below method.

ContactManager.updateMyProfile(PROFILE_OBJECT,(isSuccess, throwable, data) -> {
if (isSuccess) {
//Profile Updated. Update the UI
} else {
//Profile update failed print throwable to find the exception details
}
});
info

In profile object for image property set the absolute file path of a file if a image file needs to be uploaded or else set it to profile image id.

Refer this doc to know more about Profile Class

ArgumentDescriptionData type
PROFILE_OBJECTProfileProfile object which the updated value
CALLBACKFlyCallbackFlyCallback implemented as as lambda expression

Update profile image#

To update your profile image call the below method.

ContactManager.updateMyProfileImage(PROFILE_IMAGE_FILE,(isSuccess, throwable, data) -> {
if (isSuccess) {
Profile myProfile = (Profile) data.get("data");
//Profile image Updated. Update the UI
} else {
//Profile image update failed print throwable to find the exception details
}
});
ArgumentTypeDescription
PROFILE_IMAGE_FILEFilefile object of the profile image
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Refer Profile to know more about Profile class.

Remove profile image#

To remove your profile image call the below method.

ContactManager.removeProfileImage((isSuccess, throwable, data) -> {
if (isSuccess) {
//Profile image removed. Update the UI
} else {
//Removing profile image failed print throwable to find the exception details
}
});
ArgumentTypeDescription
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

All the contact related operation will be found below.

Contact Sync#

If mobile number is used as a primary id for communication in chat sdk then there has to be sync between user and server. The following code block initiate the contact sync and let the user communicate with their contacts who uses the client app too. This method will take care sandbox mode contact sync or live mode contact sync based on setIsTrialLicenceKey provided.

Note : In order to sync mobile contacts need to enable ChatManager.enableMobileNumberLogin

FlyCore.syncContacts(IS_FIRST_TIME, (isSuccess, throwable, data) -> {
if (isSuccess) {
// Contact Sync Success Reload Contact list
} else {
}
});
ArgumentTypeDescription
IS_FIRST_TIMEbooleantrue for first time and false after when synchronising contacts
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

To avoid unnecessay multiple contact sync calls observe the status of the contact sync beore calling syncContacts.

FlyCore.getContactSyncState().observe(getViewLifecycleOwner(), result -> {
if (result instanceof Result.Success) {}
else if (result instanceof Result.Error) {}
else if (result instanceof Result.InProgress) { }
});

The value of the contactSyncState can also be accessible by directly calling the get value method since it's a live data variable.

Result<Boolean> contactSyncStateResult = FlyCore.getContactSyncState().getValue();

Revoke Contact Sync#

If mobile number is used as a primary id for communication in chat sdk and contact sync have been completed then the following code block will delete user contacts and revoke the contact sync.

FlyCore.revokeContactSync((isSuccess, throwable, data) -> {
if (isSuccess) {
// Revoke Contact Sync Success Reload Contact list
} else {
}
});
ArgumentTypeDescription
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Friends#

The contacts who are in your contacts after the contact sync is considered as your friends, those people's only observe your profile,user presence updates.

Profile Details#

Every single chat contact has been modelled after ProfileDetails class. It holds the data of a user name, display picture, whether you blocked them or not etc. Refer Class documentation to know about ProfileDetails Class

Get Friends List#

Once we started communicating , we can get the list of contact with chat data with whom we communicated so far.

FlyCore.getFriendsList(FETCH_FROM_SERVER,(isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<ProfileDetails> friendsLitst = (ArrayList<ProfileDetails>) data.get("data");
//Friends list fetched. Update the UI
} else {
//Fetching friends list failed print throwable to find the exception details
}
});

Refer this doc to know more about ProfileDetails Class

ArgumentDescriptionData type
FETCH_FROM_SERVERProfileProfile object which the updated value
caution

FlyCallback which is used as a callback for most of the i/o operation is expressed as lambda expression for easy reading.

Get Non Chat Users List#

If mobile number login is enabled in ChatSDK then users who aren't chat user but in your contacts will be available by calling the below method.

ArrayList<ProfileDetails> nonChatUsersList = FlyCore.getNonChatUsers();

Refer this doc to know more about ProfileDetails Class

ArgumentDescriptionData type
FETCH_FROM_SERVERProfileProfile object which the updated value
caution

FlyCallback which is used as a callback for most of the i/o operation is expressed as lambda expression for easy reading.

Block a User#

To block a user call the below method.

FlyCore.blockUser(JID_TO_BLOCK,(isSuccess, throwable, data) -> {
if (isSuccess) {
//User is blocked update the UI
} else {
//User blocking failed print throwable to find the exception details
}
});
ArgumentTypeDescription
JID_TO_BLOCKStringJID of the user
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Unblock a User#

To unblock a user who is blocked already call the below method.

FlyCore.unblockUser(JID_TO_UNBLOCK,(isSuccess, throwable, data) -> {
if (isSuccess) {
//User is unblocked update the UI
} else {
//User unblocking failed print throwable to find the exception details
}
});
ArgumentTypeDescription
JID_TO_UNBLOCKStringJID of the user
CALLBACKFlyCallbackFlyCallback implemented as lambda expression
caution

Blocking and Unblocking valid for Single chat user only not for Group/Broadcast.

Get user profiles that you blocked#

To get the list of chat user profiles that you blocked call the below method.

FlyCore.getUsersIBlocked(SERVER_CALL,(isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<ProfileDetails> profilesList = (ArrayList<ProfileDetails>) data.get("data")
} else {
//Getting users that you blocked failed print throwable to find the exception details
}
});
ArgumentDescriptionType
SERVER_CALLbooleantrue to get the synced list from server false to get the list from local data. default value is false
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Note : To make server call internet connection is required

Get user profiles that blocked you#

To get the list of single chat user that blocked you call the below method.

FlyCore.getUsersWhoBlockedMe(SERVER_CALL,(isSuccess, throwable, data) -> {
if (isSuccess) {
ArrayList<ProfileDetails> profilesList = ( ArrayList<ProfileDetails>) data.get("data")
} else {
//Getting users blocked me list failed print throwable to find the exception details
}
});
ArgumentTypeDescription
SERVER_CALLbooleantrue to get the synced list from server false to get the list from local data. default value is false
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Note : To make server call internet connection is required

Get Unknown single chat Profiles#

To get the list of single chat user those are not in your contacts if you use phone number as your primary way of communication .

List<ProfileDetails> unknownProfilesList = FlyCore.getUnKnownProfiles();

Get current User status#

User can get their current user status using the below method.

ProfileStatus myUserStatus = FlyCore.getMyProfileStatus();

Refer this doc to know more about ProfileStatus Class

Get current User busy status#

User can get their current user busy status using the below method.

BusyStatus myBusyStatus = FlyCore.getMyBusyStatus();

Refer this doc to know more about BusyStatus Class

Set User status#

User can set the status for their profile using the below method.

FlyCore.setMyProfileStatus(STATUS_TEXT,(isSuccess, throwable, data) -> {
if (isSuccess) {
// Status Set
} else {
}
});
ArgumentTypeDescription
STATUS_TEXTStringStatus text cannot be longer than 140 characters
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Set User Busy status#

User can set the busy status message for their one to one chat conversation using the below method.

FlyCore.setMyBusyStatus(BUSY_STATUS_TEXT);
ArgumentTypeDescription
BUSY_STATUS_TEXTStringbusy status text cannot be longer than 140 characters

Enable/Disable User Busy status#

User can enable and disable their busy status using the below method.

FlyCore.enableDisableBusyStatus(ENABLE_BUSY_STATUS);
ArgumentTypeDescription
ENABLE_BUSY_STATUSbooleantrue enables busy status and false disables busy status

Check User Busy status is enabled#

User can check whether their busy status is enabled or disabled.

boolean isMyBusyStatusEnabled = FlyCore.isBusyStatusEnabled();

Get the list of User saved profile statuses#

User can get their list of previously saved user statuses by calling the below method.

List<ProfileStatus> myStatusList = FlyCore.getProfileStatusList();
info

This list contains some pre defined values.

Get the list of User saved busy statuses#

User can get their list of previously saved user busy statuses by calling the below method.

List<BusyStatus> myBusyStatusList = FlyCore.getBusyStatusList();
info

This list also contains some pre defined values.

Delete a user Status#

User can delete their user status by calling the below method.

FlyCore.deleteProfileStatus(USER_STATUS);
ArgumentTypeDescription
USER_STATUSProfileStatusObject of the profile status that has to be deleted
caution

User cannot delete a status which is currently selected.

Delete a user Busy Status#

User can delete their busy status by calling the below method.

FlyCore.deleteBusyStatus(USER_BUSY_STATUS);
ArgumentTypeDescription
USER_BUSY_STATUSBusyStatusObject of the user busy status that has to be deleted
caution

User cannot delete a busy status which is currently selected.

Enable disable hide seen status#

Hide Last seen status enables the user's last logged in time unavailable to their friends. To enable or disable the hide last seen status of the user call the below method.

FlyCore.enableDisableHideLastSeen( ENABLE_LAST_SEEN,(isSuccess, throwable, data) -> {
if (isSuccess) {
// Last seen status updated successfully
} else {
// updation failed print throwable for more info
}
});
ArgumentTypeDescription
ENABLE_LAST_SEENbooleantrue enables the last seen available to friends false disables it
CALLBACKFlyCallbackFlyCallback implemented as lambda expression

Check last seen status#

To check whether last seen status is available to friends or not, call the below method.

boolean lastSeenStatus = FlyCore.isLastSeenEnabled();