更新时间:2024-06-07 08:55:18下载pdf
接口说明
- (void)fetchMessageListWithListRequestModel:(ThingSmartMessageListRequestModel *)listRequestModel
success:(void (^)(NSArray<ThingSmartMessageListModel *> *messageList))success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
listRequestModel | 消息列表请求模型 |
success | 成功回调,返回消息数组 |
failure | 失败回调,返回失败原因 |
ThingSmartMessageListRequestModel
数据模型
字段 | 说明 |
---|---|
msgType | 消息类型:
|
limit | 消息列表的最大请求数量 |
offset | 已请求的消息列表总量 |
示例代码
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
}
接口说明
- (void)fetchEncryptMessageDetailListWithListRequestModel:(ThingSmartMessageDetailListRequestModel *)detailListRequestModel
success:(void (^)(NSArray<ThingSmartMessageListModel *> *messageList))success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
detailListRequestModel | 消息详情请求模型 |
success | 成功回调,返回消息详情数组 |
failure | 失败回调,返回失败原因 |
ThingSmartMessageDetailListRequestModel
数据模型
字段 | 说明 |
---|---|
msgType | 消息类型, 仅支持告警消息ThingMessageTypeAlarm |
limit | 详情列表的最大请求数量 |
offset | 已请求的详情列表总量 |
msgSrcId | 发送告警消息的设备 ID |
示例代码
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
}
接口说明
- (void)fetchMessageDecryptKeyWithEncryptRequestModel:(NSArray<ThingSmartMessageEncryptRequestModel *> *)encryptRequestListModel
success:(void (^)(NSArray<ThingSmartMessageDecryptModel *> *messageList))success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
encryptRequestListModel | 消息秘钥请求模型数组 |
success | 成功回调,返回消息秘钥数组 |
failure | 失败回调,返回失败原因 |
ThingSmartMessageEncryptRequestModel
数据模型
字段 | 说明 |
---|---|
businessNo | 消息 ID |
deviceId | 发送告警消息的设备 ID |
homeId | 家庭 ID |
time | 消息时间戳 |
ThingSmartMessageDecryptModel
数据模型
字段 | 说明 |
---|---|
businessNo | 消息 ID |
businessKey | 消息秘钥 |
示例代码
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
}
接口说明
- (void)deleteMessageWithDeleteRequestModel:(ThingSmartMessageListDeleteRequestModel *)deleteRequestModel
success:(ThingSuccessBOOL)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
deleteRequestModel | 删除消息请求模型 |
success | 成功回调 |
failure | 失败回调,返回失败原因 |
ThingSmartMessageListDeleteRequestModel
数据模型
字段 | 说明 |
---|---|
msgType | 消息类型:
|
msgIds | 待删除的消息列表 |
msgSrcId | 待删除的告警消息列表 |
msgSrcIds
。ids
。msgIds
。不可以同时设置 msgSrcIds
和 ids
参数,否则 详情列表 中的消息将无法被删除。
示例代码
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
}
接口说明
- (void)getLatestMessageWithSuccess:(ThingSuccessDict)success failure:(ThingFailureError)failure
参数说明
参数 | 说明 |
---|---|
success | 成功回调,返回字典类型,包含的字典 Key 有:
|
failure | 失败回调,返回失败原因 |
请求不同的 ThingSmartMessageListRequestModel
的 msgType
会有不同新消息判断逻辑。
对于家庭消息和通知消息,当有新消息时,调用 getLatestMessageWithSuccess:failure:
后会返回 true
。在调用 查询消息列表 之后,再次调用 getLatestMessageWithSuccess:failure:
时,状态结果将被置为 false
。
对于告警消息,当调用 readMessageWithReadRequestModel:success:failure:
后,再调用 查询消息列表 时,ThingSmartMessageListModel
的 hasNotRead
字段会被置为 false
。
示例代码
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)")
}
})
接口说明
- (void)readMessageWithReadRequestModel:(ThingSmartMessageListReadRequestModel *)readRequestModel
success:(ThingSuccessBOOL)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
readRequestModel | 已读消息请求模型 |
success | 成功回调 |
failure | 失败回调,返回失败原因 |
ThingSmartMessageListReadRequestModel
数据模型
字段 | 说明 |
---|---|
msgType | 消息类型,仅支持告警消息ThingMessageTypeAlarm |
msgIds | 已读消息列表 |
示例代码
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
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈