Skip to content

Device Sharing

Feature Description

You can share your devices to other users through the device sharing feature so that the sharing recipients can control your devices.

See QuecDeviceModel Definition in Device Management.

kotlin
QuecDeviceShareService

Device Sharing

Query Device Information by Share Code

API

Query the device information by a share code.

kotlin
fun getDeviceInfoByShareCode(
    shareCode: String,
    callback: QuecCallback<QuecDeviceModel>
)

Parameter

ParameterRequiredDescription
shareCodeYShare code.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.getDeviceInfoByShareCode("code") {
    if (it.isSuccess) {
        val data = it.data //Query the device information by a share code successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Change Shared Device Name

API

Change the name of the shared device.

kotlin
fun updateDeviceNameByShareUser(
    deviceName: String,
    shareCode: String,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
deviceNameYDevice name.
shareCodeYShare code.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.updateDeviceNameByShareUser("name", "code") {
    if (it.isSuccess) {
        //Change the name of the shared device successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Get Device Shared Recipient List

API

Get the recipient list to whom the group is shared.

kotlin
fun getDeviceShareUserList(
    deviceKey: String,
    productKey: String,
    callback: QuecCallback<List<QuecShareUserModel>>
)

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
callbackYCallback function of the request.

QuecShareUserModel Definition

FieldTypeDescription
shareInfoQuecShareUserShareInfoModelSharing information.
userInfoQuecShareUserInfoModelUser information.

QuecShareUserShareInfoModel Definition

FieldTypeDescription
acceptTimeStringTime to accept the sharing.
acceptingExpireAtStringExpiration time of accepting the sharing.
coverMarkintOverwrite flag.
deviceNameStringDevice name.
dkStringDeviceKey.
ownerUidStringOwner ID.
pkStringProductKey.
shareCodeStringShare code.
shareIdStringSharing ID.
shareStatusintSharing status.
shareTimeStringTime to create the sharing.
shareUidStringUser ID of the share recipient.
sharingExpireAtStringExpiration time of the sharing after the sharing is accepted.
updateTimeStringUpdate time.

QuecShareUserInfoModel Definition

FieldTypeDescription
addressStringAddress.
emailStringEmail address.
headimgStringProfile.
lastLoginTimeStringLast login time.
nikeNameStringNickname.
phoneStringPhone number.
registerTimeStringRegistration time.
sexStringGender.
uidStringUser ID.
userDomainStringUser domain.
userTypeintUser source.
wchartIdStringWeChat ID.
wchartNameStringWeChat name.

Example

kotlin
QuecDeviceShareService.getDeviceShareUserList("deviceKey", "productKey") {
    if (it.isSuccess) {
        val data = it.data //Get the recipient list to whom the group is shared successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Initiator Cancel Sharing

API

The share initiator cancels the sharing.

kotlin
fun unShareDeviceByOwner(
    shareCode: String,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
shareCodeYShare code.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.unShareDeviceByOwner("code") {
    if (it.isSuccess) {
        //The share initiator cancels the sharing successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Recipient Cancel Sharing

API

The share recipient cancels the sharing.

kotlin
fun unShareDeviceByShareUser(
    shareCode: String,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
shareCodeYShare code.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.unShareDeviceByShareUser("code") {
    if (it.isSuccess) {
        //The share recipient cancels the sharing successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Accept Sharing

API

The share recipient accepts the sharing.

kotlin
fun acceptShareByShareUser(
    shareCode: String,
    deviceName: String?,
    callback: QuecCallback<Unit>
)

Parameter

ParameterRequiredDescription
shareCodeYShare code.
deviceNameYDevice name.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.acceptShareByShareUser("code", "name") {
    if (it.isSuccess) {
        //The share recipient accepts the sharing successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Set Device Sharing Information

API

Set the sharing information of the device.

kotlin
fun setShareInfoByOwner(
    deviceKey: String,
    productKey: String,
    acceptingExpireTime: Long,
    coverMark: Int,
    isSharingAlwaysValid: Boolean,
    sharingExpireTime: Long,
    callback: QuecCallback<String>
)

Parameter

ParameterRequiredDescription
deviceKeyYDeviceKey.
productKeyYProductKey.
acceptingExpireTimeYExpiration time of the shared QR code, in milliseconds. This share will expire if it is not used before the expiration time.
coverMarkYOverwrite flag. Default value: 1.
1 Directly overwrite the previous valid share (overwrite the existing sharing code)
2 Add a new share directly, allowing multiple shares to coexist
3 Overwrite the previous share only when the sharing time is extended.
isSharingAlwaysValidNWhether the device sharing is permanently valid.
sharingExpireTimeNExpiration time of the device usage, in milliseconds. The shared group can be used by the recipient before the expiration time. This parameter is invalid when isSharingAlwaysValid = YES.
callbackYCallback function of the request.

Example

kotlin
QuecDeviceShareService.setShareInfoByOwner(
    "deviceKey",
    "productKey",
    0,
    1,
    true,
    System.currentTimeMillis() + 60000
) {
    if (it.isSuccess) {
        val data = it.data //Set the sharing information of the group successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}