Message DND Settings

Last Updated on : 2025-01-03 02:11:39download

This topic describes how to configure Do Not Disturb (DND) for device messages.

DND on/off

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

Parameter description

Parameter Type Description
open Boolean The on/off status.
callback IThingDataCallback<Boolean> The result callback.

Example

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 DND on/off status

fun getNoDisturbStatus(callback: IThingDataCallback<Boolean>?)

Parameter description

Parameter Type Description
callback IThingDataCallback<Boolean> The result callback.

Example

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 a list of DND periods

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

Parameter description

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

Example

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 device list in a home

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

Parameter description

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

Example

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 DND periods

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

Parameter description

Parameter Type Description
startTime String The start time of the specified DND period.
endTime String The end time of the specified DND period.
devIds String The device ID.
loops String The recurrence cycle.
callback IThingDataCallback<Long> The result callback.

Example

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);
    }
})

Modify DND periods

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

Parameter description

Parameter Type Description
nodisturbAlarmId Long The ID of the specified DND period.
mStartTime String The start time of the specified DND period.
mEndTime String The end time of the specified DND period.
devIds String The device ID.
loops String The recurrence cycle.
callback IThingDataCallback<Boolean> The result callback.

Example

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 DND periods

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

Parameter description

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

Example

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 privacy authorization on/off status

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

Parameter description

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

Example

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 privacy authorization status

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

Parameter description

Parameter Type Description
params String The on/off status of the specified authorization.
listener Business.ResultListener<Boolean> The result callback.

Example

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?) {
    }
})