Skip to content

Phone Number

This section introduces how to use the phone number to register and log in an account.

Feature Description

kotlin
QuecUserService

Query Whether Phone Number is Registered

API

Query whether the phone number is registered.

kotlin
fun queryPhoneIsRegister(
    phone: String, internationalCode: String?, callback: QuecCallback<Boolean>
)

Description

ParameterRequiredDescription
phoneYPhone number.
internationalCodeNCountry code, such as +86.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.queryPhoneIsRegister("13000000000", "+86") {
    if (it.isSuccess) {
        val value = it.data //True means registered, and false means not registered.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Log in with Phone Number and Password

API

Log in with phone number and password.

kotlin
fun loginByPhone(
    phone: String, password: String, internationalCode: String?, callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneYPhone number.
passwordYPassword.
internationalCodeNCountry code. Default: +86.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.loginByPhone("13000000000", "password", "+86") {
    if (it.isSuccess) {
        //Log in with phone number and password successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Log in with Phone Number and SMS Verification Code

API

Log in with phone number and SMS verification code. The SMS verification code should be obtained before login.

kotlin
fun loginWithMobile(
    mobile: String, code: String, internationalCode: String?, callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
mobileYPhone number.
codeYVerification code.
internationalCodeNCountry code. Default: +86.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.loginWithMobile("13000000000", "code", "+86") {
    if (it.isSuccess) {
        //Log in with phone number and SMS verification code successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Register with Phone Password

API

Register with phone password. The SMS verification code should be obtained before registration.

kotlin
fun registerByPhone(
    phone: String,
    code: String,
    password: String,
    internationalCode: String,
    callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneYPhone number.
codeYVerification code.
passwordYPassword.
internationalCodeNCountry code. Default: +86.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.registerByPhone("13000000000", "code", "password", "+86") {
    if (it.isSuccess) {
        //Register with phone password successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Send SMS Verification Code

API

Send the SMS verification code for password reset, login, registration, deregistration or value-added service recipients.

kotlin
fun sendVerifyCodeByPhone(
    phone: String, internationalCode: String?, type: Int, callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneYPhone number.
internationalCodeYCountry code.
typeYVerification code type.
1-Registration
2-Password reset
3-Login
4-Deregistration
5-Value-added service recipient
callbackYCallback function of the request.

Example

kotlin
QuecUserService.sendVerifyCodeByPhone("13000000000", "+86", 1) {
    if (it.isSuccess) {
        //Send SMS verification code successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Verify International Phone Number Format

API

Verify the international phone number format.

kotlin
fun validateInternationalPhone(
    phone: String, internationalCode: String, callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneYPhone number.
internationalCodeYCountry code.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.validateInternationalPhone("13000000000", "+86") {
    if (it.isSuccess) {
        //Verify international phone number format successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Verify SMS Verification Code

API

Verify the SMS verification code. The SMS verification code should be obtained before login.

kotlin
fun validateSmsCode(
    phone: String,
    smsCode: String,
    internationalCode: String?,
    type: Int?,
    callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneYPhone number.
smsCodeYVerification code.
internationalCodeNCountry code.
typeNWhether the verification code is invalid after verification. Defalut: 1.
1- Invalid
2-Valid
callbackYCallback function of the request.

Example

kotlin
QuecUserService.validateSmsCode("13000000000", "code", "+86", 1) {
    if (it.isSuccess) {
        //Verify the SMS verification code successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Reset Password with Phone Number and Verification Code

API

Reset the password with phone number and verification code.

kotlin
fun resetPasswordByPhone(
    phone: String,
    code: String,
    internationalCode: String?,
    password: String?,
    callback: QuecCallback<Unit>
)

Description

ParameterRequiredDescription
phoneNPhone number.
codeYVerification code.
internationalCodeNCountry code to be used in conjunction with the phone number. Default: +86.
passwordNThe reset password. If not entered, the default value is 12345678.
callbackYCallback function of the request.

Example

kotlin
QuecUserService.resetPasswordByPhone("13000000000", "code", "+86", "newPwd") {
    if (it.isSuccess) {
        //Reset the password with phone number and verification code successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}