Skip to content

Account Details

This section introduces how to manage user's profile.

Feature Description

In this module, you can call QuecUserService to obtain all information of the current user and related login and registration methods. QuecUserModel is shown in the following table:

FieldTypeDescription
nikeNameStringNickname.
phoneStringPhone number.
registerTimeStringRegistration time.
sexStringGender.
timezoneStringTime zone.
uidStringUser ID.
wchartIdStringWechat ID.
wchartNameStringWechat name.
addressStringAddress.
emailStringEmail address.
headimgStringProfile photo.
langStringLanguage.
lastLoginTimeStringLast login time.
nationalityStringNationality.
kotlin
QuecUserService

Trigger Callback of Invalid Login Status

API

Trigger the callback when the login status is invalid.

kotlin
fun setTokenInvalidCallBack(callBack: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the setting.

Example

kotlin
QuecUserService.setTokenInvalidCallBack {
    //Process when the login status is invalid.
}

Change Login Phone Number

API

Change user's login phone number.

kotlin
fun updatePhone(
    newPhone: String,
    newInternationalCode: String,
    newPhoneCode: String,
    oldPhone: String,
    oldInternationalCode: String,
    oldPhoneCode: String,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
newPhoneYNew phone number.
newInternationalCodeYCountry code of the new phone number.
newPhoneCodeYVerification code that the new phone number received.
oldPhoneYOld phone number.
oldInternationalCodeYCountry code of the old phone number.
oldPhoneCodeYVerification code that the old phone number received.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.updatePhone("13000000001", "+86", "code1", "13000000000", "+86", "code2") {
    if (it.isSuccess) {
        //Change user's login phone number successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Change Profile Photo

API

Change the profile photo by inputting the image path.

kotlin
fun updateUserIcon(imagePath: String, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
imagePathYImage path.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.updateUserIcon("https://xxx.com/xxx.jpg") {
    if (it.isSuccess) {
        //Change the profile photo successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Change Nickname

API

Change the nickname.

kotlin
fun updateUserNickName(nikeName: String, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
nikeNameYNickname.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.updateUserNickName("nickName") {
    if (it.isSuccess) {
        //Change the nickname successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Change User's Gender

API

Modify the user's gender.

kotlin
fun updateUserSex(sex: Int, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
sexYGender.
0: Male
1: Female
2: Confidential
callbackYCallback function of the request.

Example

kotlin
QuecUserService.updateUserSex(1) {
    if (it.isSuccess) {
        //Modify the user's gender successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Change Password

API

Change the password.

kotlin
fun updatePassword(newPassword: String, oldPassword: String, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
newPasswordYNew password.
oldPasswordYOld Password.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.updatePassword("newPwd", "oldPwd") {
    if (it.isSuccess) {
        //Change the password successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Delete Current User

API

Delete the current user.

kotlin
fun deleteUser(type: Int?, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
typeNDeletion type. Default value: 2.
1- Delete immediately
2- Delete after 7 days
callbackYCallback function of the request.

Example

kotlin
QuecUserService.deleteUser(1) {
    if (it.isSuccess) {
        //Delete the current user successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Obtain User Information

API

Obtain user information.

kotlin
fun getUserInfo(callback: QuecCallback<QuecUserModel>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the request.

Example

kotlin
QuecUserService.getUserInfo {
    if (it.isSuccess) {
        val value = it.data //Obtain user information successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Log Out

API

Log out.

kotlin
fun logout(callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the request.

Example

kotlin
QuecUserService.logout {
    if (it.isSuccess) {
        //Log out successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Check Login Status

API

Check the login status.

kotlin
fun checkUserLoginState(callback: QuecCallback<Boolean>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the request.

Example

kotlin
QuecUserService.checkUserLoginState {
    if (it.isSuccess) {
        val value = it.data //Check the login status successfully. True: logged in; false: not Logged in.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}