Last Updated on : 2024-06-12 08:48:54download
API description
- (void)fetchMessageListWithListRequestModel:(ThingSmartMessageListRequestModel *)listRequestModel
success:(void (^)(NSArray<ThingSmartMessageListModel *> *messageList))success
failure:(ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
listRequestModel | The model to request the list of messages. |
success | The success callback, returning an array of messages. |
failure | The failure callback, returning an error message. |
Data model of ThingSmartMessageListRequestModel
Field | Description |
---|---|
msgType | The message type:
|
limit | The maximum number of results that can be requested. |
offset | The total number of returned results. |
Example
Objective-C:
ThingSmartMessageListRequestModel *requestModel = [[ThingSmartMessageListRequestModel alloc] init];
requestModel.msgType = ThingMessageTypeAlarm;
requestModel.offset = 0;
requestModel.limit = 15;
ThingSmartMessage *message = [[ThingSmartMessage alloc] init];
[message fetchMessageListWithListRequestModel:requestModel success:^(NSArray<ThingSmartMessageListModel *> * _Nonnull messageList) {
} failure:^(NSError *error) {
}];
Swift:
let requesModel = ThingSmartMessageListRequestModel()
requesModel.msgType = .alarm
requesModel.limit = 15
requesModel.offset = 0
let message = ThingSmartMessage()
message.fetchList(with: requesModel) { list in
} failure: { error in
}
API description
- (void)fetchEncryptMessageDetailListWithListRequestModel:(ThingSmartMessageDetailListRequestModel *)detailListRequestModel
success:(void (^)(NSArray<ThingSmartMessageListModel *> *messageList))success
failure:(ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
detailListRequestModel | The model to request the message details. |
success | The success callback, returning an array of message details. |
failure | The failure callback, returning an error message. |
Data model of ThingSmartMessageDetailListRequestModel
Field | Description |
---|---|
msgType | The message type. Only the alert type ThingMessageTypeAlarm is supported. |
limit | The maximum number of results that can be requested. |
offset | The total number of returned results. |
msgSrcId | The ID of the device that sends the alert. |
Example
Objective-C:
ThingSmartMessageDetailListRequestModel *listRequestModel = [[ThingSmartMessageDetailListRequestModel alloc] init];
listRequestModel.msgType = ThingMessageTypeAlarm;
listRequestModel.limit = 15;
listRequestModel.offset = 0;
listRequestModel.msgSrcId = @"xxx";
ThingSmartMessage *message = [[ThingSmartMessage alloc] init];
[message fetchEncryptMessageDetailListWithListRequestModel:listRequestModel success:^(NSArray<ThingSmartMessageListModel *> * _Nonnull messageList) {
} failure:^(NSError *error) {
}];
Swift:
let requesModel = ThingSmartMessageDetailListRequestModel()
requesModel.msgType = .alarm
requesModel.limit = 15
requesModel.offset = 0
requesModel.msgSrcId = ""
let message = ThingSmartMessage()
message.fetchEncryptMessageDetailList(with: requesModel) { list in
} failure: { error in
}
API description
- (void)fetchMessageDecryptKeyWithEncryptRequestModel:(NSArray<ThingSmartMessageEncryptRequestModel *> *)encryptRequestListModel
success:(void (^)(NSArray<ThingSmartMessageDecryptModel *> *messageList))success
failure:(ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
encryptRequestListModel | The model to request the message key. |
success | The success callback, returning an array of message keys. |
failure | The failure callback, returning an error message. |
Data model of ThingSmartMessageEncryptRequestModel
Field | Description |
---|---|
businessNo | The message ID. |
deviceId | The ID of the device that sends the alert. |
homeId | The home ID. |
time | The message timestamp. |
Data model of ThingSmartMessageDecryptModel
Field | Description |
---|---|
businessNo | The message ID. |
businessKey | The message key. |
Example
Objective-C:
ThingSmartMessageEncryptRequestModel *requestModel = [[ThingSmartMessageEncryptRequestModel alloc] init];
requestModel.businessNo = message.msgId;
requestModel.deviceId = message.msgSrcId;
requestModel.time = message.time;
requestModel.homeId = message.homeID;
ThingSmartMessage *message = [[ThingSmartMessage alloc] init];
[messagefetchMessageDecryptKeyWithEncryptRequestModel:@[requestModel] success:^(NSArray<ThingSmartMessageDecryptModel *> * _Nonnull decryptList) {
} failure:^(NSError *error) {
}];
Swift:
let requesModel = ThingSmartMessageEncryptRequestModel()
requestModel.businessNo = message.msgId
requestModel.deviceId = message.msgSrcId
requestModel.time = message.time
requestModel.homeId = message.homeID
let message = ThingSmartMessage()
message.fetchDecryptKey(withEncryptRequestModel: [requesModel]) { list in
} failure: { error in
}
API description
- (void)deleteMessageWithDeleteRequestModel:(ThingSmartMessageListDeleteRequestModel *)deleteRequestModel
success:(ThingSuccessBOOL)success
failure:(ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
deleteRequestModel | The model to delete messages. |
success | The success callback. |
failure | The failure callback, returning an error message. |
Data model of ThingSmartMessageListDeleteRequestModel
Field | Description |
---|---|
msgType | The message type:
|
msgIds | The list of messages to be deleted. |
msgSrcId | The list of alert messages to be deleted. |
msgSrcIds
.ids
.msgIds
.Do not set both msgSrcIds
and ids
at the same time. Otherwise, the messages from the details list cannot be deleted.
Example
Objective-C:
ThingSmartMessageListDeleteRequestModel *requestModel = [[ThingSmartMessageListDeleteRequestModel alloc] init];
requestModel.msgType = ThingMessageTypeAlarm;
requestModel.msgSrcIds = @[@"xx", @"xx"];
ThingSmartMessage *message = [[ThingSmartMessage alloc] init];
[message deleteMessageWithDeleteRequestModel:requestModel success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift:
let requesModel = ThingSmartMessageListDeleteRequestModel()
requesModel.msgType = .alarm
requesModel.msgSrcIds = ["xx", "xx"]
let message = ThingSmartMessage()
message.delete(with: requesModel) { result in
} failure: { error in
}
API description
- (void)getLatestMessageWithSuccess:(ThingSuccessDict)success failure:(ThingFailureError)failure
Parameters
Parameter | Description |
---|---|
success | The success callback, returning a dictionary with the following keys:
|
failure | The failure callback, returning an error message. |
The logic for checking for new messages varies by msgType
in ThingSmartMessageListRequestModel
.
When a new home message or notice arrives, getLatestMessageWithSuccess:failure:
returns true
. When you call getLatestMessageWithSuccess:failure:
after querying the message list, the result will be set to false
.
For alert messages, when you query the message list after readMessageWithReadRequestModel:success:failure:
, hasNotRead
in ThingSmartMessageListModel
will be set to false
.
Example
Objective-C:
// self.smartMessage = [[ThingSmartMessage alloc] init];
[self.smartMessage getLatestMessageWithSuccess:^(NSDictionary *result) {
NSLog(@"get latesMessage success:%@", result);
} failure:^(NSError *error) {
NSLog(@"get message max time failure:%@", error);
}];
Swift:
smartMessage?.getLatestMessageWithSuccess({ (result) in
print("get message max time success :\(result)")
}, failure: { (error) in
if let e = error {
print("get message max time failure: \(e)")
}
})
API description
- (void)readMessageWithReadRequestModel:(ThingSmartMessageListReadRequestModel *)readRequestModel
success:(ThingSuccessBOOL)success
failure:(ThingFailureError)failure;
Parameters
Parameter | Description |
---|---|
readRequestModel | The model to request the read messages. |
success | The success callback. |
failure | The failure callback, returning an error message. |
Data model of ThingSmartMessageListReadRequestModel
Field | Description |
---|---|
msgType | The message type. Only the alert type ThingMessageTypeAlarm is supported. |
msgIds | The list of read messages. |
Example
Objective-C:
ThingSmartMessageListReadRequestModel *requestModel = [[ThingSmartMessageListReadRequestModel alloc] init];
requestModel.msgType = ThingMessageTypeAlarm;
requestModel.msgIds = @[@"xx", @"xx"];
ThingSmartMessage *message = [[ThingSmartMessage alloc] init];
[message readMessageWithReadRequestModel:requestModel success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Swift:
let requesModel = ThingSmartMessageListReadRequestModel()
requesModel.msgType = .alarm
requesModel.msgIds = ["xx", "xx"]
let message = ThingSmartMessage()
message.read(with: requesModel) { result in
} failure: { error in
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback