English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Configure Push Notifications

Last Updated on : 2022-01-04 07:29:27download

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 TYSuccessBOOL)success failure:(__nullable TYFailureError)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

[[TuyaSmartSDK 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 TYSuccessHandler)success failure:(__nullable TYFailureError)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;
[[TuyaSmartSDK 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 TYSuccessBOOL)success failure:(__nullable TYFailureError)failure

Parameters

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

Example

[[TuyaSmartSDK 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 TYSuccessHandler)success failure:(__nullable TYFailureError)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;
[[TuyaSmartSDK sharedInstance] setDevicePushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of home messages

API description

- (void)getFamilyPushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure

Parameters

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

Example

[[TuyaSmartSDK 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 TYSuccessHandler)success failure:(__nullable TYFailureError)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;
[[TuyaSmartSDK sharedInstance] setFamilyPushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of notifications

API description

- (void)getNoticePushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure

Parameters

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

Example

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

}];

Enable or disable notifications

API description

- (void)setNoticePushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)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;
[[TuyaSmartSDK sharedInstance] setNoticePushStatusWithStauts:enable  success:^{
	// This feature is set.
} failure:^(NSError *error) {

}];

Query status of promotions

API description

- (void)getMarketingPushStatusWithSuccess:(__nullable TYSuccessBOOL)success failure:(__nullable TYFailureError)failure

Parameters

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

Example

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

}];

Enable or disable promotions

API description

- (void)setMarketingPushStatusWithStauts:(BOOL)enable success:(__nullable TYSuccessHandler)success failure:(__nullable TYFailureError)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;
[[TuyaSmartSDK 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:(TYSuccessHandler)success failure:(TYFailureError)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

//TuyaSmartMessageSetting *messageSetting = [[TuyaSmartMessageSetting 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:(TYSuccessBOOL)success failure:(TYFailureError)failure

Parameters

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

Example

//TuyaSmartMessageSetting *messageSetting = [[TuyaSmartMessageSetting 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:(TYSuccessList)success failure:(TYFailureError)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

//TuyaSmartMessageSetting *messageSetting = [[TuyaSmartMessageSetting 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:(TYSuccessList)success failure:(TYFailureError)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

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

}];

Add a DND period

API description

- (void)addDNDWithDNDRequestModel:(TuyaSmartMessageSettingDNDRequestModel *)requestModel success:(TYSuccessHandler)success failure:(TYFailureError)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

//TuyaSmartMessageSettingDNDRequestModel *requestModel = [[TuyaSmartMessageSettingDNDRequestModel 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;
//TuyaSmartMessageSetting *messageSetting = [[TuyaSmartMessageSetting 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:(TuyaSmartMessageSettingDNDRequestModel *)requestModel success:(TYSuccessHandler)success failure:(TYFailureError)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

//TuyaSmartMessageSettingDNDRequestModel *requestModel = [[TuyaSmartMessageSettingDNDRequestModel 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;
//TuyaSmartMessageSetting *messageSetting = [[TuyaSmartMessageSetting 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:(TYSuccessHandler)success failure:(TYFailureError)failure

Parameters

Parameter Description
timerID The timer ID.
success The success callback.
failure The failure callback. An error message is returned.

Example

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

}];