Message Capabilities

Last Updated on : 2023-05-22 06:38:25

Query a list of messages

API description

void getMessageList(ITuyaDataCallback<List<MessageBean>> callback);

Parameters

Parameter Description
callback The success or failure callback.

Data model of MessageBean

Field Type Description
dateTime String The date and time.
Icon String The URL of the message icon.
msgTypeContent String The name of the message type.
msgContent String The content of the message.
msgType Integer The type of message.
msgSrcId String The device ID. Only an alert has this parameter.
id String The message ID.

Example

TuyaHomeSdk.getMessageInstance().getMessageList(new ITuyaDataCallback<List<MessageBean>>() {
    @Override
    public void onSuccess(List<MessageBean> result) {}
    @Override
    public void onError(String errorCode, String errorMessage) {}
});

Query a list of messages on pages

API description

void getMessageList(int offset, int limit, ITuyaDataCallback<MessageListBean> callback);

Parameters

Parameter Description
offset The total number of messages already returned.
limit The maximum number of entries to be returned per page.
callback The success or failure callback.

Example

TuyaHomeSdk.getMessageInstance().getMessageList(offset, limit, new ITuyaDataCallback<MessageListBean>() {
            @Override
            public void onSuccess(MessageListBean result) {}
            @Override
            public void onError(String errorCode, String errorMessage) {}
});

Query messages on pages by message type

API description

void getMessageListByMsgType(int offset, int limit, MessageType msgType, final ITuyaDataCallback<MessageListBean> callback);

Parameters

Parameter Description
offset The total number of messages already returned.
limit The maximum number of entries to be returned per page.
msgType The type of message. Valid values:
  • 1: alert
  • 2: home message
  • 3: notification
callback The success or failure callback.

Example

TuyaHomeSdk.getMessageInstance().getMessageListByMsgType(offset, limit, type, new ITuyaDataCallback<MessageListBean>() {
            @Override
            public void onSuccess(MessageListBean result) {}
            @Override
            public void onError(String errorCode, String errorMessage) {}
});

Query messages on pages by msgSrcId

Returns a list of messages by msgSrcId. Only the alerts of MSG_REPORT type are supported.

API description

void getMessageListByMsgSrcId(int offset, int limit, MessageType msgType, String msgSrcId, ITuyaDataCallback<MessageListBean> callback);

Parameters

Parameter Description
offset The entry number starting from which data is returned.
limit The number of entries returned per page.
msgType The type of message. Only the alerts of MSG_REPORT type are supported.
msgSrcId The message group ID.
callback The success or failure callback.
  • To enable multiple languages for alerts, multilingual settings are required.
  • The languages of the received alerts do not change along with the mobile phone system languages.

Example

TuyaHomeSdk.getMessageInstance().getMessageListByMsgSrcId(offset, limit, MessageType.MSG_REPORT, msgSrcId, true, new ITuyaDataCallback<MessageListBean>() {
    @Override
    public void onSuccess(final MessageListBean result) {
    }
    @Override
    public void onError(String errorCode, String errorMessage) {
    }
});

Bulk delete messages

API description

void deleteMessages(List<String> mIds, IBooleanCallback callback);

Parameters

Parameter Description
mIds The list of IDs for the messages to be deleted.
callback The success or failure callback.

Example

TuyaHomeSdk.getMessageInstance().deleteMessages(mIds, new IBooleanCallback() {
    @Override
    public void onSuccess() {
    }
    @Override
    public void onError(String code, String error) {
    }
});

Bulk delete specific type of message

API description

void deleteMessageWithType(int msgType, List<String> mIds, List<String> mSrcIds, final IBooleanCallback callback);

Parameters

Parameter Description
msgType The type of message. Valid values:
  • 1: alert
  • 2: home message
  • 3: notification
mIds The list of IDs for the messages to be deleted.
mSrcIds The list of alert types. An empty value or null represents that alerts are not deleted.
callback The success or failure callback.
  • To delete items from the alert list, you must set the parameter mSrcIds.
  • To delete items from the list of alert details, you must set the parameter mIds. mSrcIds and mIds cannot be set in the same request.

Example

TuyaHomeSdk.getMessageInstance().deleteMessageWithType(msgType, mIds, mSrcIds, new IBooleanCallback() {
    @Override
    public void onSuccess() {
    }
    @Override
    public void onError(String code, String error) {
    }
});

Check for new messages

Whether messages are regarded as unread depends on different API requests. In the request for alert details, messages are marked as read. In the request for the list of other message types, the messages are marked as read. Only unread messages are new messages. The field hasNotRead of MessageBean indicates this status.

API description

void requestMessageNew(final ITuyaDataCallback<MessageHasNew> callback);

Parameters

Parameter Description
callback The callback. The latest unread messages are returned.

Data model of MessageHasNew

Field Type Description
alarm Boolean Indicates whether alerts are generated.
family Boolean Indicates whether home messages are generated.
notification Boolean Indicates whether notifications are generated.

Example

TuyaHomeSdk.getMessageInstance().requestMessageNew(new ITuyaDataCallback<MessageHasNew>() {
    @Override
    public void onSuccess(MessageHasNew result) {
    }
    @Override
    public void onError(String errorCode, String errorMessage) {
    }
});