Configure Push Notifications

Last Updated on : 2023-05-25 06:23:48

Query status of push notifications

Returns the status of the push notifications feature. If this feature is disabled, device alerts, home messages, and notifications cannot be received.

API description

- (void)getPushStatusWithSuccess:(__nullable ThingSuccessBOOL)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
success The success callback. A value of false indicates that push notifications such as device alerts, home messages, and notifications cannot be received.
failure The failure callback. An error message is returned.

Example

[[ThingSmartSDK sharedInstance] getPushStatusWithSuccess:^(BOOL result) {
	// `result == YES`: This feature is enabled.
} failure:^(NSError *error) {

}];

Enable or disable push notifications

Returns the status of the push notifications feature. If this feature is disabled, device alerts, home messages, and notifications cannot be received.

API description

- (void)setPushStatusWithStatus:(BOOL)enable success:(__nullable ThingSuccessHandler)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
enable Specifies whether to enable this feature.
success The success callback.
failure The failure callback. An error message is returned.

Example

BOOL enable = YES;
[[ThingSmartSDK sharedInstance] setPushStatusWithStatus:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Manage push notifications by message type

Query status of device alerts

API description

- (void)getDevicePushStatusWithSuccess:(__nullable ThingSuccessBOOL)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
success The success callback. A Boolean value is returned.
failure The failure callback. An error message is returned.

Example

[[ThingSmartSDK sharedInstance] getDevicePushStatusWithSuccess:^(BOOL result) {
  // `result == YES`: Device alerts are enabled.
} failure:^(NSError *error) {

}];

Enable or disable device alerts

API description

- (void)setDevicePushStatusWithStauts:(BOOL)enable success:(__nullable ThingSuccessHandler)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
enable Specifies whether to enable this feature.
success The success callback.
failure The failure callback. An error message is returned.

Example

BOOL enable = YES;
[[ThingSmartSDK sharedInstance] setDevicePushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of home messages

API description

- (void)getFamilyPushStatusWithSuccess:(__nullable ThingSuccessBOOL)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
success The success callback. A Boolean value is returned.
failure The failure callback. An error message is returned.

Example

[[ThingSmartSDK sharedInstance] getFamilyPushStatusWithSuccess:^(BOOL result) {
	// `result == YES`: Home messages are enabled.
} failure:^(NSError *error) {

}];

Enable or disable home messages

API description

- (void)setFamilyPushStatusWithStauts:(BOOL)enable success:(__nullable ThingSuccessHandler)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
enable Specifies whether to enable this feature.
success The success callback.
failure The failure callback. An error message is returned.

Example

BOOL enable = YES;
[[ThingSmartSDK sharedInstance] setFamilyPushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of notifications

API description

- (void)getNoticePushStatusWithSuccess:(__nullable ThingSuccessBOOL)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
success The success callback. A Boolean value is returned.
failure The failure callback. An error message is returned.

Example

[[ThingSmartSDK sharedInstance] getNoticePushStatusWithSuccess:^(BOOL result) {
	// `result == YES`: Notifications are enabled.
} failure:^(NSError *error) {

}];

Enable or disable notifications

API description

- (void)setNoticePushStatusWithStauts:(BOOL)enable success:(__nullable ThingSuccessHandler)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
enable Specifies whether to enable or disable the notification feature. A value of YES represents that this feature is enabled.
success The success callback.
failure The failure callback. An error message is returned.

Example

BOOL enable = YES;
[[ThingSmartSDK sharedInstance] setNoticePushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of promotions

API description

- (void)getMarketingPushStatusWithSuccess:(__nullable ThingSuccessBOOL)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
success The success callback. A Boolean value is returned.
failure The failure callback. An error message is returned.

Example

[[ThingSmartSDK sharedInstance] getMarketingPushStatusWithSuccess:^(BOOL result) {
	// `result == YES`: Promotions are enabled.
} failure:^(NSError *error) {

}];

Enable or disable promotions

API description

- (void)setMarketingPushStatusWithStauts:(BOOL)enable success:(__nullable ThingSuccessHandler)success failure:(__nullable ThingFailureError)failure

Parameters

Parameter Description
enable Specifies whether to enable this feature.
success The success callback.
failure The failure callback. An error message is returned.

Example

BOOL enable = YES;
[[ThingSmartSDK sharedInstance] setMarketingPushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Set DND periods

Enable or disable DND for push notifications

API description

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

Parameters

Parameter Description
flags Specifies whether to enable this feature.
success The success callback.
failure The failure callback. An error message is returned.

Example

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
BOOL flags = YES;
[messageSetting setDeviceDNDSettingStatus:flags success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query DND status for push notifications

API description

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

Parameters

Parameter Description
success The success callback. A Boolean value is returned.
failure The failure callback. An error message is returned.

Example

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDeviceDNDSettingstatusSuccess:^(BOOL result){
	// `result == YES`: DND is enabled for push notifications.
} failure:^(NSError *error) {

}];

Query a list of DND periods

API description

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

Parameters

Parameter Description
success The success callback with an array of DND periods returned.
failure The failure callback. An error message is returned.

Example

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDListSuccess:^(NSArray *list){
	// A list of DND periods is returned.
} failure:^(NSError *error) {

}];

Query devices for all homes

API description

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

Parameters

Parameter Description
success The success callback with a list of devices for all homes returned.
failure The failure callback. An error message is returned.

Example

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
[messageSetting getDNDDeviceListSuccess:^(NSArray *list){
	// A list of devices is returned.
} failure:^(NSError *error) {

}];

Add a DND period

API description

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

Parameters

Parameter Description
requestModel The model to add a DND period. The following parameters are included:
  • startTime: the start time.
  • endTime: the end time.
  • devIDs: the list of device IDs.
  • loops: the number of times the scheduled task weekly recurs.
  • isAllDevIDs: specifies whether all devices support DND periods.
success The success callback.
failure The failure callback. An error message is returned.

Example

//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:^{
	// The DND period is added.
} failure:^(NSError *error) {

}];

Modify a DND period

API description

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

Parameters

Parameter Description
timerID The timer ID.
requestModel The model to add a DND period. The following parameters are included:
  • startTime: the start time.
  • endTime: the end time.
  • devIDs: the list of device IDs.
  • loops: the number of times the scheduled task weekly recurs.
  • isAllDevIDs: specifies whether all devices support DND periods.
success The success callback.
failure The failure callback. An error message is returned.

Example

//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:^{
	// The DND period is modified.
} failure:^(NSError *error) {

}];

Remove a DND 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. An error message is returned.

Example

//ThingSmartMessageSetting *messageSetting = [[ThingSmartMessageSetting alloc] init];
//long timerID = 1108056;
[messageSetting removeDNDWithTimerID:timerID success:^{
	// The DND period is removed.
} failure:^(NSError *error) {

}];