设备消息免打扰管理

更新时间:2024-08-16 09:00:27下载pdf

本文介绍设备消息免打扰相关配置。

设置免打扰开关状态

接口说明

- (void)setDeviceDNDSettingStatus:(BOOL)flags success:(ThingSuccessHandler)success failure:(ThingFailureError)failure

参数说明

参数 说明
flags 开启或关闭免打扰
success 成功回调
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
BOOL flags = YES;
[messageSetting setDeviceDNDSettingStatus:flags success:^{
    // 设置成功
} failure:^(NSError *error) {

}];

查询是否开启免打扰

接口说明

- (void)getDeviceDNDSettingstatusSuccess:(ThingSuccessBOOL)success failure:(ThingFailureError)failure

参数说明

参数 说明
success 成功回调,返回布尔值
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDeviceDNDSettingstatusSuccess:^(BOOL result){
    // 当 result == YES 时,表示设备消息免打扰开关状态为开启
} failure:^(NSError *error) {

}];

查询所有家庭下所有设备列表

接口说明

- (void)getDNDDeviceListSuccess:(ThingSuccessList)success failure:(ThingFailureError)failure

参数说明

参数 说明
success 成功回调,返回所有家庭下所有设备列表数组
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDDeviceListSuccess:^(NSArray *list){
    //获取设备列表成功
} failure:^(NSError *error) {

}];

查询周期性免打扰时段列表

周期性免打扰指的是同一个免打扰时段,可以设置为一周内重复生效。例如,周一到周五的 8:00-12:00 处于免打扰时间段内,不会收到设备告警消息。

接口说明

- (void)getDNDListSuccess:(ThingSuccessList)success failure:(ThingFailureError)failure

参数说明

参数 说明
success 成功回调,返回时间段数组
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDListSuccess:^(NSArray *list){
    //获取消息免打扰时间段列表成功
} failure:^(NSError *error) {

}];

添加周期性免打扰时段

接口说明

- (void)addDNDWithDNDRequestModel:(ThingSmartMessageSettingDNDRequestModel *)requestModel success:(ThingSuccessHandler)success failure:(ThingFailureError)failure

参数说明

参数 说明
requestModel 添加消息免打扰请求模型:
  • startTime:开始时间
  • endTime:结束时间
  • devIDs:设备 ID 列表
  • loops:每周重复次数
  • isAllDevIDs:所有设备是否都支持免打扰设置(DND)
success 成功回调
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSettingDNDRequestModel *requestModel = [[ThingSmartMessageSettingDNDRequestModel alloc] init];
//requestModel.startTime = @"07:10";
//requestModel.endTime = @"23:00";
//requestModel.devIDs = @[@"***",@"***"];
//0 means close that day, 1 means open on the day. @"0000111" means Friday to Sunday open. That's the same thing as index =0 starting on Monday
//requestModel.loops = @"0000111";
//requestModel.isAllDevIDs = YES;
//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting addDNDWithDNDRequestModel:requestModel success:^{
    //添加成功
} failure:^(NSError *error) {

}];

修改周期性免打扰时段

接口说明

- (void)modifyDNDWithTimerID:(long)timerID DNDRequestModel:(ThingSmartMessageSettingDNDRequestModel *)requestModel success:(ThingSuccessHandler)success failure:(ThingFailureError)failure

参数说明

参数 说明
timerID 免打扰时间段 ID
requestModel 修改消息免打扰请求模型:
  • startTime:开始时间
  • endTime:结束时间
  • devIDs:设备 ID 列表
  • loops:每周重复次数
  • isAllDevIDs:所有设备是否都支持免打扰设置(DND)
success 成功回调
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSettingDNDRequestModel *requestModel = [[ThingSmartMessageSettingDNDRequestModel alloc] init];
//requestModel.startTime = @"07:10";
//requestModel.endTime = @"23:00";
//requestModel.devIDs = @[@"***",@"***"];
//0 means close that day, 1 means open on the day. @"0000111" means Friday to Sunday open. That's the same thing as index =0 starting on Monday
//requestModel.loops = @"0000111";
//requestModel.isAllDevIDs = YES;
//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
//long timerID = 1108056;
[messageSetting modifyDNDWithTimerID:timerID DNDRequestModel:requestModel success:^{
    //修改成功
} failure:^(NSError *error) {

}];

移除免打扰时段

接口说明

- (void)removeDNDWithTimerID:(long)timerID success:(ThingSuccessHandler)success failure:(ThingFailureError)failure

参数说明

参数 说明
timerID 定时器 ID
success 成功回调
failure 失败回调,返回失败原因

示例代码

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
//long timerID = 1108056;
[messageSetting removeDNDWithTimerID:timerID success:^{
    //移除成功
} failure:^(NSError *error) {

}];