Do-not-disturb Management for Device Messages

Last Updated on : 2024-08-16 09:00:27download

This topic introduces how to configure do-not-disturb settings for device messages.

Set the status of do-not-disturb switch

API description

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

Parameters

Parameter Description
flags Specifies whether to turn the do-not-disturb switch on or off.
success The success callback.
failure The failure callback, which returns a failure reason.

Sample code

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
BOOL flags = YES;
[messageSetting setDeviceDNDSettingStatus:flags success:^{
    // Set the status successfully.
} failure:^(NSError *error) {

}];

Query whether the do-not-disturb switch is turned on

API description

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

Parameters

Parameter Description
success The success callback, which returns a Boolean value.
failure The failure callback, which returns a failure reason.

Sample code

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDeviceDNDSettingstatusSuccess:^(BOOL result){
    // If result is YES, the do-not-disturb switch is turned on for device messages.
} failure:^(NSError *error) {

}];

Query the device lists of all homes

API description

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

Parameters

Parameter Description
success The success callback, which returns an array of device lists of all homes.
failure The failure callback, which returns a failure reason.

Sample code

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDDeviceListSuccess:^(NSArray *list){
    // Get device lists successfully.
} failure:^(NSError *error) {

}];

Query the list of recurrent do-not-disturb periods

A recurrent do-not-disturb period can take effect repeatedly within a week. For example, during the do-not-disturb period from 8:00 to 12:00 on Monday to Friday, you do not receive any device alerts.

API description

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

Parameters

Parameter Description
success The success callback, which returns an array of time periods.
failure The failure callback, which returns a failure reason.

Sample code

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDListSuccess:^(NSArray *list){
    // Get the list of do-not-disturb periods successfully.
} failure:^(NSError *error) {

}];

Add a recurrent do-not-disturb period

API description

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

Parameters

Parameter Description
requestModel The request model for adding a do-not-disturb period.
  • startTime: the start time
  • endTime: the end time
  • devIDs: the device ID list
  • loops: the number of recurrences each week
  • isAllDevIDs: specifies whether all devices support the do-not-disturb settings
success The success callback.
failure The failure callback, which returns a failure reason.

Sample code

//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:^{
    // Add a do-not-disturb period successfully.
} failure:^(NSError *error) {

}];

Modify a recurrent do-not-disturb period

API description

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

Parameters

Parameter Description
timerID The ID of a do-not-disturb period.
requestModel The request model for modifying a do-not-disturb period.
  • startTime: the start time
  • endTime: the end time
  • devIDs: the device ID list
  • loops: the number of recurrences each week
  • isAllDevIDs: specifies whether all devices support the do-not-disturb settings
success The success callback.
failure The failure callback, which returns a failure reason.

Sample code

//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:^{
    // Modify the do-not-disturb period successfully.
} failure:^(NSError *error) {

}];

Remove a do-not-disturb period

API description

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

Parameters

Parameter Description
timerID The timer ID.
success The success callback.
failure The failure callback, which returns a failure reason.

Sample code

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
//long timerID = 1108056;
[messageSetting removeDNDWithTimerID:timerID success:^{
    // Remove the do-not-disturb period successfully.
} failure:^(NSError *error) {

}];