Last Updated on : 2024-08-22 02:51:09download
This topic introduces how to manage the push of messages.
The ThingSmartBusinessExtensionKit component offers more features than the ThingSmartMessage. If you are still using ThingSmartMessage, please refer to this document.
You can query the status of a message push switch by message type. Messages fall into the following types:
API description
- (void)getMessagePushSwitchStatusWithType:(ThingSmartMessagePushSwitchType)type
success:(ThingSuccessBOOL _Nullable)success
failure:(ThingFailureError _Nullable)failure;
Parameters
| Parameter | Description |
|---|---|
| type | The message type. Valid values:
|
| success | The success callback, which returns the status of the message push switch. |
| failure | The failure callback, which returns a failure reason. |
Sample code
Objective-C
[[ThingSmartMessagePushSetting new] getMessagePushSwitchStatusWithType:ThingSmartMessagePushSwitchTypeFamily success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift
ThingSmartMessagePushSetting().getMessagePushSwitchStatus(with: .family) { result in
} failure: { error in
}
API description
- (void)setMessagePushSwitchStatusWithRequestModel:(ThingSmartMessagePushSwitchRequestModel *_Nonnull)requestModel
success:(__nullable ThingSuccessHandler)success
failure:(__nullable ThingFailureError)failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartMessagePushSwitchRequestModel
| Field | Description |
|---|---|
| type | The message type. Valid values:
|
| open | The switch status. |
Sample code
Objective-C
ThingSmartMessagePushSwitchRequestModel *requesModel = [[ThingSmartMessagePushSwitchRequestModel alloc] init];
requesModel.open = open;
requesModel.type = type;
[[ThingSmartMessagePushSetting new] setMessagePushSwitchStatusWithRequestModel:requesModel success:^{
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartMessagePushSwitchRequestModel()
requestModel.open = true
requestModel.type = .family
ThingSmartMessagePushSetting().setMessagePushSwitchStatusWith(requestModel) {
} failure: { erro in
}
Users can receive device alerts through three channels: system message push, phone call, and SMS message. For these channels, you can set their switch status respectively. To activate phone call or SMS notifications, you need to purchase a value-added service. For more information, contact your account manager. In addition, you can integrate Advanced Functions UI BizBundle to access the service purchase page for users.
API description
- (void)getDeviceAlarmSwitchStatusWithPushChannel:(ThingSmartDeviceAlarmPushChannel)pushChannel
success:(ThingSuccessBOOL _Nullable)success
failure:(ThingFailureError _Nullable)failure;
Parameters
| Parameter | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| success | The success callback, which returns the status of the message push switch. |
| failure | The failure callback, which returns a failure reason. |
Sample code
Objective-C
[[ThingSmartMessagePushSetting new] getDeviceAlarmSwitchStatusWithPushChannel:ThingSmartDeviceAlarmPushChannelSystem success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift
ThingSmartMessagePushSetting().getDeviceAlarmSwitchStatus(with: .system) { result in
} failure: { error in
}
API description
- (void)setDeviceAlarmSwitchStatusWithRequestModel:(ThingSmartDeviceAlarmSwitchRequestModel *_Nonnull)requestModel
success:(__nullable ThingSuccessHandler)success
failure:(__nullable ThingFailureError)failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmSwitchRequestModel
| Field | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| open | The switch status. |
Sample code
Objective-C
ThingSmartDeviceAlarmSwitchRequestModel *requestModel = [[ThingSmartDeviceAlarmSwitchRequestModel alloc] init];
requestModel.open = YES;
requestModel.pushChannel = ThingSmartDeviceAlarmPushChannelSystem;
[[ThingSmartMessagePushSetting new] setDeviceAlarmSwitchStatusWithRequestModel:requestModel success:^{
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartDeviceAlarmSwitchRequestModel()
requestModel.open = true
requestModel.pushChannel = .system
ThingSmartMessagePushSetting().setDeviceAlarmSwitchStatusWith(requestModel) {
} failure: { erro in
}
API description
- (void)getDeviceAlarmThrottleTimeWithPushChannel:(ThingSmartDeviceAlarmPushChannel)pushChannel
success:(ThingSuccessInt _Nullable )success
failure:(ThingFailureError _Nullable )failure;
Parameters
| Parameter | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| success | The success callback, which returns the throttle time in minutes. |
| failure | The failure callback, which returns a failure reason. |
Sample code
Objective-C
[[ThingSmartMessagePushSetting new] getDeviceAlarmThrottleTimeWithPushChannel:ThingSmartDeviceAlarmPushChannelSystem success:^(int result) {
} failure:^(NSError *error) {
}];
Swift
ThingSmartMessagePushSetting().getDeviceAlarmThrottleTime(with: .system) { time in
} failure: { error in
}
API description
- (void)setDeviceAlarmThrottleTimeWithRequestModel:(ThingSmartDeviceAlarmThrottleTimeRequestModel *_Nonnull)requestModel
success:(__nullable ThingSuccessBOOL)success
failure:(__nullable ThingFailureError)failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmThrottleTimeRequestModel
| Field | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| minute | The throttle time in minutes. |
Sample code
Objective-C
ThingSmartDeviceAlarmThrottleTimeRequestModel *requestModel = [[ThingSmartDeviceAlarmThrottleTimeRequestModel alloc] init];
requestModel.minute = 10;
requestModel.pushChannel = ThingSmartDeviceAlarmPushChannelSystem;
[[ThingSmartMessagePushSetting new] setDeviceAlarmThrottleTimeWithRequestModel:requestModel success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartDeviceAlarmThrottleTimeRequestModel()
requestModel.minute = 10
requestModel.pushChannel = .system
ThingSmartMessagePushSetting().setDeviceAlarmThrottleTimeWith(requestModel) { result in
} failure: { error in
}
API description
- (void)getDeviceAlarmServiceInfoWithRequestModel:(ThingSmartDeviceAlarmServiceRequestModel *_Nonnull)requestModel
success:(void(^_Nullable)(NSArray <ThingSmartDeviceAlarmServiceInfoEntity *>* _Nullable result))success
failure:(ThingFailureError _Nullable )failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback, which returns a list of device alert configurations. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmServiceRequestModel
| Field | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| homeId | The home ID. |
| deviceId | The device ID. |
Data model of ThingSmartDeviceAlarmServiceInfoEntity
| Field | Description |
|---|---|
| configId | The configuration ID. |
| configName | The configuration name. |
| selected | Specifies whether the configuration is selected. |
Sample code
Objective-C
ThingSmartDeviceAlarmServiceRequestModel *requestModel = [[ThingSmartDeviceAlarmServiceRequestModel alloc] init];
requestModel.deviceId = deviceId;
requestModel.pushChannel = pushChannel;
requestModel.homeId = familyId;
[[ThingSmartMessagePushSetting new] getDeviceAlarmServiceInfoWithRequestModel:requestModel success:^(NSArray<ThingSmartDeviceAlarmServiceInfoEntity *> * _Nullable result) {
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartDeviceAlarmServiceRequestModel()
requestModel.homeId = 123
requestModel.deviceId = "xx"
requestModel.pushChannel = .system
ThingSmartMessagePushSetting().getDeviceAlarmServiceInfo(requestModel) { list in
} failure: { error in
}
API description
- (void)setDeviceAlarmServiceInfoWithRequestModel:(ThingSmartDeviceAlarmServiceUpdateRequestModel *_Nonnull)requestModel
success:(ThingSuccessBOOL _Nullable )success
failure:(ThingFailureError _Nullable )failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmServiceUpdateRequestModel
| Field | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| homeId | The home ID. |
| deviceId | The device ID. |
| configIds | The configuration ID list. |
Sample code
Objective-C
ThingSmartDeviceAlarmServiceUpdateRequestModel *requestModel = [[ThingSmartDeviceAlarmServiceUpdateRequestModel alloc] init];
requestModel.deviceId = deviceId;
requestModel.pushChannel = pushChannel;
requestModel.configIds = configIds;
requestModel.homeId = familyId;
[[ThingSmartMessagePushSetting new] setDeviceAlarmServiceInfoWithRequestModel:requestModel success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartDeviceAlarmServiceUpdateRequestModel()
requestModel.homeId = 123
requestModel.deviceId = "xx"
requestModel.pushChannel = .system
requestModel.configIds = ["xx","xx"]
ThingSmartMessagePushSetting().setDeviceAlarmServiceInfoWith(requestModel) { result in
} failure: { erro in
}
Currently, you can query the purchase information of the phone call or SMS notification service.
API description
- (void)getDeviceAlarmPurchaseInfoWithPushChannel:(ThingSmartDeviceAlarmPushChannel)pushChannel
success:(void(^_Nullable)(ThingSmartDeviceAlarmPurchaseEntity * _Nullable result))success
failure:(ThingFailureError _Nullable )failure;
Parameters
| Parameter | Description |
|---|---|
| pushChannel | The message push channel. Valid values:
|
| success | The success callback, which returns the purchase information. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmPurchaseEntity
| Field | Description |
|---|---|
| expireDate | The expiration time. |
| packageStatus | The purchase status. Valid values:
|
| remainingTimes | The remaining number of times. |
| packageDesc | The description. |
Sample code
Objective-C
[[ThingSmartMessagePushSetting new] getDeviceAlarmPurchaseInfoWithPushChannel:channel success:^(ThingSmartDeviceAlarmPurchaseEntity * _Nullable result) {
} failure:^(NSError *error) {
}];
Swift
ThingSmartMessagePushSetting().getDeviceAlarmPurchaseInfo(with: .phone) { result in
} failure: { error in
}
Currently, you can query the list of devices with alerts pushed through phone calls or SMS messages.
API description
- (void)getDeviceAlarmListWithRequestModel:(ThingSmartDeviceAlarmListRequestModel *_Nonnull)requestModel
success:(void(^_Nullable)(ThingSmartDeviceAlarmListEntity * _Nullable result))success
failure:(ThingFailureError _Nullable )failure;
Parameters
| Parameter | Description |
|---|---|
| requestModel | The request model. |
| success | The success callback, which returns a device list. |
| failure | The failure callback, which returns a failure reason. |
Data model of ThingSmartDeviceAlarmListRequestModel
| Field | Description |
|---|---|
| pageNumber | The page number. |
| pageSize | The page size. |
| homeId | The home ID. |
| pushChannel | The message push channel. Valid values:
|
Data model of ThingSmartDeviceAlarmListEntity
| Field | Description |
|---|---|
| hasMore | Specifies whether more data is available. |
| devices | The device list. |
Data model of ThingSmartDeviceAlarmItemEntity
| Field | Description |
|---|---|
| deviceId | The device ID. |
| name | The device name. |
| iconUrl | The device icon. |
| selectedNum | The number of alert configurations selected for a device. |
| totalNum | The total number of alert configurations. |
Sample code
Objective-C
ThingSmartDeviceAlarmListRequestModel *requestModel = [[ThingSmartDeviceAlarmListRequestModel alloc] init];
requestModel.pushChannel = ThingSmartDeviceAlarmPushChannelPhone;
requestModel.pageNumber = 1;
requestModel.pageSize = 15;
requestModel.homeId = familyId;
[[ThingSmartMessagePushSetting new] getDeviceAlarmListWithRequestModel:requestModel success:^(ThingSmartDeviceAlarmListEntity * _Nullable result) {
} failure:^(NSError *error) {
}];
Swift
let requestModel = ThingSmartDeviceAlarmListRequestModel()
requestModel.homeId = 123
requestModel.pageSize = 15
requestModel.pageNumber = 1
requestModel.pushChannel = .phone
ThingSmartMessagePushSetting().getDeviceAlarmList(with: requestModel) { list in
} failure: { error in
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback