Message Management

Last Updated on : 2024-09-05 03:18:58download

This topic describes how to use the message data model and related interfaces for message processing. You can easily implement operations like message query, mark-as-read, deletion, and getting encryption keys. You will get to know the specific uses, parameters, and usage examples of various interfaces. Hence you can step on a fast track to integrating these features into your applications.

Message data model

Attribute type description

The message data model contains a set of attributes, such as home, icon, and message type.

All messages in the Message Center BizBundle SDK are described using MessageBean, with attribute type descriptions as follows:

Attribute Type Description
extendParams String The extended parameter.
isNeedPullEncKey Boolean Specifies whether to get the encryption key to decrypt the image.
isExpirePics Boolean Specifies whether the image has expired.
isExpireVideos Boolean Specifies whether the video has expired.
homeId String The ID of the home.
homeName String The name of the home.
encryptKey String The encryption key.
hasNotRead Boolean Specifies whether the message is unread.
alarmType Int The type of the alert.
dateTime String The date and time. Format: 2017-09-08 17:12:45
icon String The URL of the message icon.
msgTypeContent String The name of the message type.
msgContent String The message content.
attachPics String The name of the attachment image.
id String The ID of the message.
msgType Int The type of the message.
msgSrcId String The device ID.
choose Boolean Specifies whether it is selected.
actionURL String The URL of the action.
time Long The timestamp.
messageAttach MessageAttach The attachment of the message.
attachVideos List<String> The list of videos in the attachment.
attachAudios List<String> The list of audio in the attachment.

Message list

Query the message list of a specified type

To update messages, get the message list of a specified type.

fun requestMessageListByType(
        offset: Int,
        limit: Int,
        msgType: MessageType,
        callback: IThingDataCallback<MessageListBean>?
    )

Parameters

Parameter Type Description
offset Int The start position to get the message.
limit Int The number of messages to get per page.
msgType MessageType The type of the message to get.
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().requestMessageListByType(10, 20, MSG_REPORT, new IThingDataCallback<MessageListBean>() {
    @Override
    public void onSuccess(MessageListBean result) {
        mBeanResult.t.postValue(change(msgType, result, null));
        mBeanResult.networkState.postValue(NetworkState.SUCCESS);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        mBeanResult.networkState.postValue(NetworkState.falied(errorCode,
                errorMessage));
    }
})

Query the message details list of a specified type

fun getMessageListByMsgSrcId(
        offset: Int,
        limit: Int,
        msgType: Int,
        msgSrcId: String?,
        encryptImage: Boolean,
        callback: IThingDataCallback<MessageListBean>?
    )

Parameters

Parameter Type Description
offset Int The start position to get the message.
limit Int The number of messages to get per page.
msgType Int The type of the message to get.
msgSrcId String The unique identifier of the message group.
encryptImage Boolean Specifies whether to encrypt the image.
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getMessageListByMsgSrcId(0, 0, 0,"id", true, new IThingDataCallback<MessageListBean>() {
    @Override
    public void onSuccess(MessageListBean result) {
        mBeanResult.t.postValue(change(msgType, result, null));
        mBeanResult.networkState.postValue(NetworkState.SUCCESS);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        mBeanResult.networkState.postValue(NetworkState.failed(errorCode, errorMessage));
    }
})

Query the encrypted message details list of a specified type

fun getMsgListBySrcIdSplitEncryptImageKey(
        offset: Int,
        limit: Int,
        msgType: Int,
        msgSrcId: String?,
        encryptImage: Boolean,
        splitImageKey: Boolean,
        callback: IThingDataCallback<MessageListBean>?
    )

Parameters

Parameter Type Description
offset Int The start position to get the message.
limit Int The number of messages to get per page.
msgType Int The type of the message to get.
msgSrcId String The unique identifier of the message group.
encryptImage Boolean Specifies whether to encrypt the image.
splitImageKey Boolean Specifies whether to call the decryption interface.
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getMsgListBySrcIdSplitEncryptImageKey(0, 0, 0, "id", true, true, 
         mMessageCore.requestMessageListByType(offset, limit, type, new IThingDataCallback<MessageListBean>() {
            @Override
            public void onSuccess(MessageListBean result) {
                mBeanResult.t.postValue(change(msgType, result, null));
                mBeanResult.networkState.postValue(NetworkState.SUCCESS);
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                mBeanResult.networkState.postValue(NetworkState.failed(errorCode, errorMessage));
            }
        });
)

Query whether there are new messages

fun requestMessageNew(callback: IThingDataCallback<MessageHasNew?>?)

Parameters

Parameter Type Description
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().requestMessageNew(object : IThingDataCallback<MessageHasNew?> {
    override fun onSuccess(messageHasNew: MessageHasNew?) {
        if (messageHasNew != null) {
            val hasNew = (messageHasNew.isAlarm || messageHasNew.isFamily || messageHasNew.isNotification)
            ThingSecurityPreferenceGlobalUtil.set(
                PreferencesContants.MESSAGE_ALARM_HAS_NEW,
                messageHasNew.isAlarm
            )
            ThingSecurityPreferenceGlobalUtil.set(
                PreferencesContants.MESSAGE_FAMILY_HAS_NEW,
                messageHasNew.isFamily
            )
            ThingSecurityPreferenceGlobalUtil.set(
                PreferencesContants.MESSAGE_NOTIFICATION_HAS_NEW,
                messageHasNew.isNotification
            )
            resultSuccess(WHAT_REFRESH, hasNew)
        }
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})

Mark a message as read

fun readMessageByIds(
        msgType: Int,
        msgSrcId: String?,
        callback: IThingDataCallback<Boolean>?
    )

Parameters

Parameter Type Description
msgType Int The type of the message to get.
msgSrcId String The unique identifier of the message group.
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().readMessageByIds(0, "msgSrcId", object : IThingDataCallback<Boolean> {
                override fun onSuccess(result: Boolean?) {
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                }
            })

Delete a message

fun deleteMessageByIds(
        msgType: Int,
        idList: List<String>?,
        msgSrcIdList: List<String>?,
        callback: IBooleanCallback?
    )

Parameters

Parameter Type Description
msgType Int The type of the message to get.
idList List<String> The ID of the message to delete.
msgSrcIdList List<String> The source ID of the message to delete.
callback IThingDataCallback<MessageListBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().deleteMessageByIds(0, "id1,id2,id3", "srcId1,srcId2,srcId3", new IBooleanCallback() {
    @Override
    public void onSuccess() {
        mDeleteBeanLiveData.networkState.postValue(NetworkState.SUCCESS);
        mDeleteBeanLiveData.t.postValue(true);
    }

    @Override
    public void onError(String code, String error) {
        mDeleteBeanLiveData.networkState.postValue(NetworkState.failed(code, error));
    }
})

Get the key of an encrypted message

 fun getLineUUid(
        uid: String?,
        nativeUrl: String?,
        appId: Int,
        listener: Business.ResultListener<String>?
    )

Parameters

Parameter Type Description
uid String The unique identifier of the user.
nativeUrl String The local URL to the resource or page.
appId Int The identifier of the application.
listener Business.ResultListener<String> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getLineUUid(14343, "http://example.com/resource", 123, object : Business.ResultListener<String> {
    override fun onSuccess(p0: BusinessResponse?, p1: String?, p2: String?) {
        resultSuccess(WHAT_GET_UUID_SUCCESS, p1)
    }

    override fun onFailure(p0: BusinessResponse?, p1: String?, p2: String?) {
        resultError(WHAT_GET_UUID_FAILURE, p0?.getErrorCode(), p0?.getErrorMsg())
    }
})

Get home information by device ID

fun getFamilyByDevice(devId: String?, listener: Business.ResultListener<FamilyGroupBean>?)

Parameters

Parameter Type Description
devId String The ID of the device.
listener Business.ResultListener<FamilyGroupBean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getFamilyByDevice("somedevId", object : Business.ResultListener<FamilyGroupBean> {
    override fun onSuccess(result: FamilyGroupBean) {
        // Success result.
        println("Success: ${result}")
    }

    override fun onFailure(error: Throwable) {
        // Failure result.
        println("Error: ${error.message}")
    }
})

Get home information by scene ID

fun getFamilyByScene(sceneId: String?, listener: Business.ResultListener<FamilyGroupBean>?)

Parameters

Parameter Type Description
sceneId String The ID of the scene.
listener Business.ResultListener<FamilyGroupBean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getFamilyByScene("sceneId", new Business.ResultListener<FamilyGroupBean>() {
        @Override
        public void onFailure(BusinessResponse businessResponse, FamilyGroupBean groupBean, String s) {
        }

        @Override
        public void onSuccess(BusinessResponse businessResponse, final FamilyGroupBean groupBean, String s) {
        }
    })

Batch mark messages as read

fun readMessageList(
        msgType: Int,
        msgSrcIds: String?,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Type Description
msgType Int The type of the message.
msgSrcIds String The identifier of the message source.
listener Business.ResultListener<Boolean> Specifies from which message source to read the message.

Sample code

PersonalMessageCore.newThingSmartMessageCore().readMessageList(1, "source1,source2,source3", new Business.ResultListener<Boolean>() {
    @Override
    public void onFailure(BusinessResponse businessResponse, Boolean aBoolean, String s) {
        result.networkState.postValue(NetworkState.failed(businessResponse.getErrorCode(), businessResponse.getErrorMsg()));
    }

    @Override
    public void onSuccess(BusinessResponse businessResponse, Boolean aBoolean, String s) {
        result.networkState.postValue(NetworkState.SUCCESS);
        result.t.postValue(aBoolean);
    }
})

Mark all messages as read

fun readAllMessage(msgType: Int, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Type Description
msgType Int The type of the message.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().readAllMessage(msgType, new Business.ResultListener<Boolean>() {
    @Override
    public void onFailure(BusinessResponse businessResponse, Boolean aBoolean, String s) {
        result.networkState.postValue(NetworkState.failed(businessResponse.getErrorCode(), businessResponse.getErrorMsg()));
    }

    @Override
    public void onSuccess(BusinessResponse businessResponse, Boolean aBoolean, String s) {
        result.networkState.postValue(NetworkState.SUCCESS);
        result.t.postValue(aBoolean);
    }
})

Get the list of devices that support message push

fun getSupportPushDeviceList(
        homeId: Long,
        listener: Business.ResultListener<List<LinePushDeviceBean>>?
    )

Parameters

Parameter Type Description
homeId Long The ID of the home.
listener Business.ResultListener<List<LinePushDeviceBean>> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getSupportPushDeviceList(
    12345,
    object : Business.ResultListener<List<LinePushDeviceBean>> {
        override fun onSuccess(
            p0: BusinessResponse?,
            p1: List<LinePushDeviceBean>?,
            p2: String?
        ) {
            resultSuccess(WHAT_HOME_DEVICE_LIST_SUCCESS, p1)
        }

        override fun onFailure(
            p0: BusinessResponse?,
            p1: List<LinePushDeviceBean>?,
            p2: String?
        ) {
            resultError(WHAT_HOME_DEVICE_LIST_FAILURE, p0?.errorCode, p0?.errorMsg)
        }
})

Batch save device lists

fun savePushDeviceList(devIds: List<String>, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Type Description
devIds List<String> The device ID list.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().savePushDeviceList({"device1", "device2", "device3"}, object : Business.ResultListener<Boolean> {
    override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
        resultSuccess(WHAT_MESSAGE_SAVE_DEVICE_IDS_SUCCESS, null)
    }

    override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
        resultError(WHAT_MESSAGE_SAVE_DEVICE_IDS_FAILED, p0?.errorCode, p0?.errorMsg)
    }
})

Get the list of devices selected by the user for message push

fun getCheckedPushDeviceList(listener: Business.ResultListener<List<LinePushDeviceBean>>?)

Parameters

Parameter Type Description
listener Business.ResultListener<List<LinePushDeviceBean>> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getCheckedPushDeviceList(object :
    Business.ResultListener<ArrayList<LinePushDeviceBean>> {
    override fun onFailure(
        bizResponse: BusinessResponse?,
        bizResult: ArrayList<LinePushDeviceBean>?,
        apiName: String?
    ) {
        listener?.onFailure(bizResponse, bizResult, apiName)
    }

    override fun onSuccess(
        bizResponse: BusinessResponse?,
        bizResult: ArrayList<LinePushDeviceBean>?,
        apiName: String?
    ) {
        listener?.onSuccess(bizResponse, bizResult, apiName)
    }
})

Save the list of devices selected for message push

fun saveFinalPushDeviceList(devIds: List<String>, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Type Description
devIds List<String> The device ID list.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().saveFinalPushDeviceList(["device1", "device2", "device3"], object : Business.ResultListener<Boolean> {
    override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
        resultSuccess(WHAT_MESSAGE_SAVE_CHECKED_DEVICE_SUCCESS, null)
    }

    override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
        resultError(
            WHAT_MESSAGE_SAVE_CHECKED_DEVICE_FAILED,
            p0?.getErrorCode(),
            p0?.getErrorMsg()
        )
    }
})

Get the status of message push switch

fun getPushSwitchStatusByType(type: Int, listener: Business.ResultListener<Boolean>?)

Parameters

Parameter Type Description
msgType Int The type of push notification.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getPushSwitchStatusByType(
    MessageContants.LINE_PUSH_TYPE,
    object : Business.ResultListener<Boolean> {
        override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
            resultSuccess(WHAT_GET_SWITCH_STATUS_SUCCESS, p1)
        }

        override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
            resultError(
                WHAT_GET_SWITCH_STATUS_FAILURE,
                p0?.getErrorCode(),
                p0?.getErrorMsg()
            )
        }
})

Set the status of message push switch

fun setPushSwitchStatusByType(
        type: Int,
        isClose: Boolean,
        listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Type Description
type Int The type of the message.
isClose Boolean The status of the switch.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageCore().setPushSwitchStatusByType(
    MessageContants.LINE_PUSH_TYPE,
    true,
    object : Business.ResultListener<Boolean> {
        override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
            resultSuccess(WHAT_SET_SWITCH_STATUS_SUCCESS, p1)
        }

        override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
            resultError(
                WHAT_SET_SWITCH_STATUS_FAILURE,
                p0?.getErrorCode(),
                p0?.getErrorMsg()
            )
        }
    })

Get the list of message encryption image keys

fun getMessageEncryptImageKeyList(
        requestList: List<MessageEncryptImageKeyRequest>,
        callback: IThingDataCallback<List<MessageEncryptImageKeyBean>>
    )

Parameters

Parameter Type Description
requestList List<MessageEncryptImageKeyRequest> The list of requests for message encryption image keys.
callback IThingDataCallback<List<MessageEncryptImageKeyBean>> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageCore().getMessageEncryptImageKeyList(requestList,
    new IThingDataCallback<List<MessageEncryptImageKeyBean>>() {
        @Override
        public void onSuccess(List<MessageEncryptImageKeyBean> keyBeans) {
            mBeanResult.t.postValue(change(0, result, keyBeans));
            mBeanResult.networkState.postValue(NetworkState.SUCCESS);
        }

        @Override
        public void onError(String errorCode, String errorMessage) {
            mBeanResult.t.postValue(change(0, result, null));
            mBeanResult.networkState.postValue(NetworkState.SUCCESS);
        }
    })

Message settings

Do-Not-Disturb switch for messages

fun nodisturbSetting(open: Boolean, callback: IThingDataCallback<Boolean>?)

Parameters

Parameter Type Description
open Boolean The status of the switch.
callback IThingDataCallback<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().nodisturbSetting(true, new IThingDataCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbSetting onSuccess:" + result);
        }
        if (result) {
            resultSuccess(WHAT_SET_NODISTURB_STATUS_OK, open);
        }
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbSetting onFailure");
        }
    }
})

Get the do-not-disturb switch status for messages

fun getNoDisturbStatus(callback: IThingDataCallback<Boolean>?)

Parameters

Parameter Type Description
callback IThingDataCallback<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().getNoDisturbStatus(new IThingDataCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbSetting onSuccess:" + result);
        }
        resultSuccess(WHAT_GET_NODISTURB_STATUS_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbStatus onFailure");
        }
    }
})

Get the list of do-not-disturb periods for messages

fun getNodisturbList(callback: IThingDataCallback<ArrayList<DeviceAlarmNotDisturbVO>?>)

Parameters

Parameter Type Description
callback IThingDataCallback<ArrayList<DeviceAlarmNotDisturbVO>> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().getNodisturbList(new IThingDataCallback<ArrayList<com.thingclips.smart.sdk.bean.message.DeviceAlarmNotDisturbVO>>() {
    @Override
    public void onSuccess(ArrayList<com.thingclips.smart.sdk.bean.message.DeviceAlarmNotDisturbVO> result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "refreshList onSuccess:");
        }
        resultSuccess(WHAT_GET_NODISTURB_LIST_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "refreshList onFailure");
        }
    }
})

Get the list of devices of a home

fun getHomeDeviceListByIds(
        homeId: Long,
        listener: Business.ResultListener<List<LinePushDeviceBean>>?
    )

Parameters

Parameter Type Description
homeId long The ID of the home.
listener Business.ResultListener<List<LinePushDeviceBean>> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().getHomeDeviceListByIds(
    123456L,
    object : Business.ResultListener<ArrayList<LinePushDeviceBean>> {
        override fun onFailure(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<LinePushDeviceBean>?,
            apiName: String?
        ) {
            listener?.onFailure(bizResponse, bizResult, apiName)
        }

        override fun onSuccess(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<LinePushDeviceBean>?,
            apiName: String?
        ) {
            listener?.onSuccess(bizResponse, bizResult, apiName)
        }
    })

Add a do-not-disturb period for messages

fun noDisturbAddAlarm(
        startTime: String?,
        endTime: String?,
        devIds: String?,
        loops: String?,
        callback: IThingDataCallback<Long>?
    )

Parameters

Parameter Type Description
startTime String The start time of the do-not-disturb period.
endTime String The end time of the do-not-disturb period.
devIds String The ID of the device.
loops String The recurring cycle.
callback IThingDataCallback<Long> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().noDisturbAddAlarm("23:00", "07:00", "device1,device2", "daily", new IThingDataCallback<Long>() {
    @Override
    public void onSuccess(Long result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbAddAlarm onSuccess");
        }
        resultSuccess(WHAT_ADD_NODISTURB_ALARM_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbAddAlarm onFailure");
        }
        resultError(WHAT_ADD_NODISTURB_ALARM_FAIL, errorCode, errorMessage);
    }
})

Edit the do-not-disturb period

fun editNodisturbAlarm(
        nodisturbAlarmId: Long,
        mStartTime: String?,
        mEndTime: String?,
        devIds: String?,
        loops: String?,
        callback: IThingDataCallback<Boolean>?
    )

Parameters

Parameter Type Description
nodisturbAlarmId Long The do-not-disturb ID.
mStartTime String The start time of the do-not-disturb period.
mEndTime String The end time of the do-not-disturb period.
devIds String The ID of the device.
loops String The recurring cycle.
callback IThingDataCallback<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().editNodisturbAlarm(123456L, "23:00", "07:00", "device1,device2", "daily", new IThingDataCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "editNodisturbAlarm onSuccess:");
        }
        resultSuccess(WHAT_UPDATE_NODISTURB_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "editNodisturbAlarm onFailure:");
        }
        resultError(WHAT_UPDATE_NODISTURB_FAIL, errorCode, errorMessage);
    }
})

Delete a do-not-disturb period

fun removeNodisturb(id: Long, callback: IThingDataCallback<Boolean>?)

Parameters

Parameter Type Description
id long The ID.
callback IThingDataCallback<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().removeNodisturb(123456L, new IThingDataCallback<Boolean>() {
    @Override
    public void onSuccess(Boolean result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "removeNodisturbList onSuccess:");
        }
        resultSuccess(WHAT_REMOVE_NODISTURB_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "removeNodisturbList onFailure:");
        }
    }
})

Get the switch for privacy authorization

fun getPrivacyAuthorizationSwitch(
        type: AuthorizationType,
        listener: Business.ResultListener<ArrayList<UserExtraPropertyBean>>
    )

Parameters

Parameter Type Description
type AuthorizationType The type of authorization.
listener Business.ResultListener<ArrayList<UserExtraPropertyBean>> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().getPrivacyAuthorizationSwitch(
    MARKETING_PUSH,
    object : Business.ResultListener<ArrayList<UserExtraPropertyBean>> {
        override fun onFailure(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<UserExtraPropertyBean>?,
            apiName: String?
        ) {
        }

        override fun onSuccess(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<UserExtraPropertyBean>?,
            apiName: String?
        ) {
        }
    })

Set the status of privacy authorization switch

fun setPrivacyAuthorizationSwitch(
        params: String?, listener: Business.ResultListener<Boolean>?
    )

Parameters

Parameter Type Description
params String The switch information for authorization.
listener Business.ResultListener<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().setPrivacyAuthorizationSwitch("Authorization Information", object : Business.ResultListener<Boolean> {
    override fun onSuccess(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
    }
    override fun onFailure(p0: BusinessResponse?, p1: Boolean?, p2: String?) {
    }
})

Get the do-not-disturb device

fun getNoDisturbDeviceList(callback: IThingDataCallback<ArrayList<NodisturbDevicesBean>>?)

Parameters

Parameter Type Description
callback IThingDataCallback<ArrayList<NodisturbDevicesBean>> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessageSettingCore().getNoDisturbDeviceList(new IThingDataCallback<ArrayList<com.thingclips.smart.sdk.bean.message.NodisturbDevicesBean>>() {
    @Override
    public void onSuccess(ArrayList<com.thingclips.smart.sdk.bean.message.NodisturbDevicesBean> result) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbDeviceList onSuccess");
        }
        resultSuccess(WHAT_GET_NODISTURB_DEVICES_OK, result);
    }

    @Override
    public void onError(String errorCode, String errorMessage) {
        if (TOAST_DEBUG) {
            ToastUtil.shortToast(context, "noDisturbDeviceList onFailure");
        }
    }
})

Message push

Get the device alert interval

fun getNonRepeatRemindMinute(
        pushType: PushType,
        callback: IThingDataCallback<AlarmRemindBean>?
    )

Parameters

Parameter Type Description
pushType PushType The type of the alert.
callback IThingDataCallback<AlarmRemindBean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().getNonRepeatRemindMinute(PUSH_ALARM, object : IThingDataCallback<AlarmRemindBean> {
        override fun onSuccess(result: AlarmRemindBean?) {
            continuation.resume(result)
        }

        override fun onError(errorCode: String?, errorMessage: String?) {
            continuation.resumeWithException(
                ErrorException(
                    errorCode,
                    errorMessage
                )
            )
        }
    })

Set an interval for nonrecurrence of an alert

fun setSwitchStateByServer(
        pushType: PushType,
        check: Boolean,
        callback: IThingDataCallback<Boolean>?
    )

Parameters

Parameter Type Description
pushType PushType The type of the alert.
check Boolean The setting of the switch.
callback IThingDataCallback<Boolean> The callback of the query result.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().setSwitchStateByServer(pushType, check, object : IThingDataCallback<Boolean?> {
    override fun onSuccess(result: Boolean?) {
        continuation.resume(result)
    }

    override fun onError(errorCode: String?, errorMessage: String?) {
        continuation.resumeWithException(
            ErrorException(
                errorCode,
                errorMessage
            )
        )
    }
})

Get the alert service information for a device

fun getWarnDeviceConfig(
        gid: String,
        serverType: String,
        deviceId: String,
        listener: Business.ResultListener<ArrayList<WarnDeviceConfig>>?
    )

Parameters

Parameter Type Description
gid String The identifier of the device configuration group.
serverType String The type of the service.
deviceId String The ID of the device.
listener Business.ResultListener<ArrayList<WarnDeviceConfig>> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().getWarnDeviceConfig("group123", "production_server", "device001",
    object : Business.ResultListener<ArrayList<WarnDeviceConfig>> {
        override fun onFailure(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<WarnDeviceConfig>?,
            apiName: String?
        ) {
            continuation.resumeWithException(
                ErrorException(
                    bizResponse?.errorCode,
                    bizResponse?.errorMsg
                )
            )
        }

        override fun onSuccess(
            bizResponse: BusinessResponse?,
            bizResult: ArrayList<WarnDeviceConfig>?,
            apiName: String?
        ) {
            continuation.resume(bizResult)
        }
    })

Set the alert service information for a device

fun updateWarnDeviceConfig(
        noticeRuleList: WarnNoticeExpr,
        listener: Business.ResultListener<Boolean>
    )

Parameters

Parameter Type Description
noticeRuleList WarnNoticeExpr The list of alert notification rules.
listener Business.ResultListener<Boolean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().updateWarnDeviceConfig(warnNoticeExpr,
    object : Business.ResultListener<Boolean> {
        override fun onFailure(
            bizResponse: BusinessResponse?,
            bizResult: Boolean?,
            apiName: String?
        ) {
            continuation.resumeWithException(
                ErrorException(
                    bizResponse?.errorCode,
                    bizResponse?.errorMsg
                )
            )
        }

        override fun onSuccess(
            bizResponse: BusinessResponse?,
            bizResult: Boolean?,
            apiName: String?
        ) {
            continuation.resume(bizResult)
        }
    })

Get the remaining phone call notification times

fun getAlarmPhoneTimesCount(
        listener: Business.ResultListener<AlarmTimesCount>
    )

Parameters

Parameter Type Description
listener Business.ResultListener<AlarmTimesCount> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().getAlarmPhoneTimesCount(new Business.ResultListener<AlarmTimesCount>() {
    @Override
    public void onSuccess(BusinessResponse bizResponse, AlarmTimesCount bizResult, String apiName) {
        ServerStatus packageStatus = ServerStatus.Companion.getValue(bizResult.getPackageStatus());
        // If the service is not purchased, has expired, or the service status is unknown, and the feature is disabled, ignore the switch status returned from the cloud.
        if (packageStatus == ServerStatus.NOT_PURCHASED || packageStatus == ServerStatus.EXPIRED || packageStatus == ServerStatus.USED_UP) {
            setChecked(pushType, false);
        } else {
            setChecked(pushType, result);
        }
        resultSuccess(WHAT_REFRESH, null);
    }

    @Override
    public void onFailure(BusinessResponse bizResponse, AlarmTimesCount bizResult, String apiName) {

    }
})

Get the remaining SMS notification times

fun getAlarmSMSTimesCount(
        notificationType: String,
        listener: Business.ResultListener<AlarmTimesCount>
    )

Parameters

Parameter Type Description
notificationType String The type of the notification.
listener Business.ResultListener<AlarmTimesCount> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().getAlarmSMSTimesCount(ServerType.SMS.getValue(), new Business.ResultListener<AlarmTimesCount>() {
    @Override
    public void onSuccess(BusinessResponse bizResponse, AlarmTimesCount bizResult, String apiName) {
        ServerStatus packageStatus = ServerStatus.Companion.getValue(bizResult.getPackageStatus());
        if (packageStatus == ServerStatus.NOT_PURCHASED || packageStatus == ServerStatus.EXPIRED || packageStatus == ServerStatus.USED_UP) {
            setChecked(pushType, false);
        } else {
            setChecked(pushType, result);
        }
        resultSuccess(WHAT_REFRESH, null);
    }

    @Override
    public void onFailure(BusinessResponse bizResponse, AlarmTimesCount bizResult, String apiName) {

    }
})

Get the list of devices with alerts of a home

fun getWarnDeviceList(
        gid: String,
        serverType: String,
        pageNo: Int,
        pageSize: Int,
        listener: Business.ResultListener<WarnDeviceBean>
    )

Parameters

Parameter Type Description
gid String The group to which the device belongs.
serverType String The type of the service.
pageNo Int The page number.
pageSize Int The number of records per page.
listener Business.ResultListener<WarnDeviceBean> The return result of the handler function.

Sample code

PersonalMessageCore.newThingSmartMessagePushCore().getWarnDeviceList("group123", "phone_notify_server", 1, 10,
    object : Business.ResultListener<WarnDeviceBean> {
        override fun onFailure(
            bizResponse: BusinessResponse?,
            bizResult: WarnDeviceBean?,
            apiName: String?
        ) {
            continuation.resumeWithException(
                ErrorException(
                    bizResponse?.errorCode,
                    bizResponse?.errorMsg
                )
            )
        }

        override fun onSuccess(
            bizResponse: BusinessResponse?,
            bizResult: WarnDeviceBean?,
            apiName: String?
        ) {
            continuation.resume(bizResult)
        }
    })