消息推送管理

更新时间:2025-01-17 13:30:00下载pdf

本文介绍如何管理消息推送。

消息推送相关

获取消息推送开关

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

参数说明

参数 类型 说明
msgType Int 推送通知种类
listener Business.ResultListener<Boolean> 处理函数的返回结果

调用示例

PersonalMessageCore.newThingSmartMessagePushCore().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()
            )
        }
})

设置消息推送开关

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

参数说明

参数 类型 说明
type Int 消息的类型
isClose Boolean 开启状态
listener Business.ResultListener<Boolean> 处理函数的返回结果

调用示例

PersonalMessageCore.newThingSmartMessagePushCore().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()
            )
        }
    })

告警相关

获取设备告警推送通道的开关状态

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

参数说明

参数 类型 说明
msgType Int 推送通知种类
listener Business.ResultListener<Boolean> 处理函数的返回结果

调用示例

PersonalMessageCore.newThingSmartMessagePushCore().getDeviceAlarmSwitchStatusWithPushChannel(
    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()
            )
        }
})

设置设备告警推送通道的开关状态

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

参数说明

参数 类型 说明
type Int 消息的类型
isClose Boolean 开启状态
listener Business.ResultListener<Boolean> 处理函数的返回结果

调用示例

PersonalMessageCore.newThingSmartMessagePushCore().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()
            )
        }
    })

获取不重复告警的间隔时间

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

参数说明

参数 类型 说明
pushType PushType 告警类型
callback IThingDataCallback<Boolean> 查询结果的回调

调用示例

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

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

设置不重复告警的间隔时间

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

参数说明

参数 类型 说明
pushType PushType 告警类型
check Boolean 开关设置
callback IThingDataCallback<Boolean> 查询结果的回调

调用示例

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

获取单设备告警服务信息

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

参数说明

参数 类型 说明
gid String 设备配置组标识
serverType String 服务类型
deviceId String 设备 ID
listener Business.ResultListener<ArrayList<WarnDeviceConfig>> 处理函数的返回结果

调用示例

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

设置单设备告警服务信息

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

参数说明

参数 类型 说明
noticeRuleList WarnNoticeExpr 警告通知规则的列表
listener Business.ResultListener<Boolean> 处理函数的返回结果

调用示例

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

获取家庭下设备告警列表

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

参数说明

参数 类型 说明
gid String 设备所属的组别
serverType String 服务类型
pageNo Int 页码
pageSize Int 每页的记录数
listener Business.ResultListener<WarnDeviceBean> 处理函数的返回结果

调用示例

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

通知相关

获取电话剩余的通知次数

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

参数说明

参数 类型 说明
listener Business.ResultListener<AlarmTimesCount> 处理函数的返回结果

调用示例

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 (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) {

    }
})

获取短信剩余的通知次数

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

参数说明

参数 类型 说明
notificationType String 通知类型
listener Business.ResultListener<AlarmTimesCount> 处理函数的返回结果

调用示例

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

    }
})