Skip to content

Message Management

The content below introduces how to manage messages, including device alert, automation and scene execution.

Feature Description

kotlin
QuecUserMessageService

Query Message List

API

Query a message list by message type (call the new API below when reading messages by label).

kotlin
fun getUserMessageListByPageNumber(
    pageNumber: Int,
    pageSize: Int,
    msgType: Int,
    isRead: Boolean,
    deviceKey: String?,
    productKey: String?,
    callback: QuecCallback<QuecPageResponse<QuecUserMessageListModel>>
)

Parameter

ParameterRequiredDescription
pageNumberNPage number. Default value: 1.
pageSizeNPage size. Default value: 10.
msgTypeNThe random combination of the received message types. Separate multiple types by commas.
1-Device notification
2-Device alert
3-Device fault
4-System messages
isReadNWhether the message is read or not.
deviceKeyNDeviceKey.
productKeyNProductKey.
callbackYCallback function of the request.

QuecUserMessageListModel Definition

ParameterTypeDescription
msgIdStringMassage ID.
msgTypeintMessage type.
1-Device notification
2-Device alert
3-Device fault
4-System messages
isReadbooleanWhether the message is read or not.
titleStringTitle.
contentStringContent.
pkStringProductKey.
dkStringDeviceKey.
addTimelongThe time to add the message.
readTimelongThe time to read the message.
shareCodeStringShare code.
sceneIconStringScene icon.
sceneNameStringScene name.
sceneExecuteTimeStringScene execution time.
executeIdStringScene execution ID.
logIdStringAutomation log ID.
automationIdStringAutomation ID.
firstLabelStringLabel of the first-level messages.
secondaryLabelStringLabel of the second-level messages.

Example

kotlin
QuecUserMessageService.getUserMessageListByPageNumber(1, 10, 1, false, null, null) {
    if (it.isSuccess) {
        val value = it.data //Query a message list successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Read Message

API

Read a message or messages in batches (call the new API below when reading messages by label).

kotlin
fun readMessageByMsgIdList(
    msgIdList: String?,
    msgType: Int,
    callback: QuecCallback<QuecReadMsgModel>
)

Parameter

ParameterRequiredDescription
msgIdListNList of message IDs to be read. Separate multiple IDs by commas. Read all the messages if this parameter is omitted.
msgTypeNThe random combination of the received message types. Separate multiple types by commas.
1-Device notification
2-Device alert
3-Device fault
4-System messages
callbackYCallback function of the request.

QuecReadMsgModel Definition

ParameterTypeDescription
successListList<QuecReadMsgListModel>List of successful executions.
failureListList<QuecReadMsgListModel>List of failed executions.

QuecReadMsgListModel Definition

ParameterTypeDescription
msgIDStringMessage ID.
failureMsgStringReasons for reading failure (only valid for failurelist).

Example

kotlin
QuecUserMessageService.readMessageByMsgIdList("msgIdList", 1) {
    if (it.isSuccess) {
        val value = it.data //Read a message successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Delete Message

API

Delete a message.

kotlin
fun deleteMessageByMsgId(msgId: String?, language: String?, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
msgIdYList of message IDs to be read. Separate multiple IDs by commas.
languageNVoice.
callbackYCallback function of the request.

Example

kotlin
QuecUserMessageService.deleteMessageByMsgId("msgId", "cn") {
    if (it.isSuccess) {
        //Delete a message successfully. 
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Read Message

API

Read a message by label.

kotlin
fun readMessageByMsgIdList(
    msgIdList: String?,
    firstLabelList: String?,
    secondaryLabelList: String?,
    callback: QuecCallback<QuecReadMsgModel>
)

Parameter

ParameterRequiredDescription
msgIdListYList of message IDs to be read. Separate multiple IDs by commas. Read all the messages if this parameter is omitted.
firstLabelListYList of first-level messages. Separate multiple lists by commas.
1-System
2-Smart
3-Device
secondaryLabelListYList of secondary messages. Separate multiple lists by commas.
1-Privacy
2-Service
3-Automation
4-Scene
5-Device notification
6-Device alert
7-Device fault
8-OTA
callbackYCallback function of the request.

QuecReadMsgModel Definition

ParameterTypeDescription
successListList<QuecReadMsgListModel>List of successful executions.
failureListList<QuecReadMsgListModel>List of failed executions.

QuecReadMsgListModel Definition

ParameterTypeDescription
msgIDStringMessage ID.
failureMsgStringReasons for reading failure (only valid for failurelist).

Example

kotlin
QuecUserMessageService.readMessageByMsgIdList("msgIdList", "1", "1") {
    if (it.isSuccess) {
        val value = it.data //Read a message by label successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Query Unread Message Number

API

Query the number of unread messages, which can be used to mark the user's message reading state.

kotlin
fun getMsgStats(callback: QuecCallback<QuecUserMessageStatsModel>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the request.

QuecUserMessageStatsModel Definition

ParameterTypeDescription
smartQuecUserMessageUnReadModelSmart-related messages.
systemQuecUserMessageUnReadModelSystem-related messages.
deviceQuecUserMessageUnReadModelDevice-related messages.

QuecUserMessageUnReadModel Definition

ParameterTypeDescription
readintThe number of read messages.
unReadintThe number of unread messages.

Example

kotlin
QuecUserMessageService.getMsgStats {
    if (it.isSuccess) {
        val value = it.data //Query the number of unread messages successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Query Type of Push Message Received by User

API

Query the type of push messages received by user.

kotlin
fun getMsgPushSetting(callback: QuecCallback<QuecPushSettingModel>)

Parameter

ParameterRequiredDescription
callbackYCallback function of the request.

QuecPushSettingModel Definition

ParameterTypeDescription
deviceNotifybooleanDevice push.
smartNotifybooleanSmart push.
systemNotifybooleanSystem push.
deviceQuecPushSettingItemModelConfiguration state of device push sub-properties.
smartQuecPushSettingItemModelConfiguration state of smart push sub-properties.
systemQuecPushSettingItemModelConfiguration state of system push sub-properties.

QuecPushSettingItemModel Definition

ParameterTypeDescription
appbooleanWhether system push is on.
smsbooleanWhether SMS push is on.
voicebooleanWhether voice call push is on.

Example

kotlin
QuecUserMessageService.getMsgPushSetting {
    if (it.isSuccess) {
        val value = it.data //Query the type of push messages received by user successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}

Set Type of Push Message Received by User

API

Set the type of push message received by user.

kotlin
fun setMsgPushSetting(config: QuecPushSettingModel, callback: QuecCallback<Unit>)

Parameter

ParameterRequiredDescription
configYSee QuecPushSettingModel Definition above. [Query Type of Push Message Received by User]
callbackYCallback function of the request.

Example

kotlin
val config = getConfig() //Obtain configuration parameter from the cloud.
QuecUserMessageService.setMsgPushSetting(config) {
    if (it.isSuccess) {
        //Set the type of push message received by user successfully.
    } else {
        val code = it.code //Failed. Error code.
        val msg = it.msg //Failed. Error message.
    }
}