Skip to content

Commit 7c2e1c3

Browse files
committed
udpate iOS add downloadThumbImage api
1 parent f04ece3 commit 7c2e1c3

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

ios/RCTJMessageModule/RCTJMessageModule.m

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,62 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
16641664
}];
16651665
}
16661666

1667+
RCT_EXPORT_METHOD(downloadThumbImage:(NSDictionary *)param
1668+
successCallback:(RCTResponseSenderBlock)successCallback
1669+
failCallback:(RCTResponseSenderBlock)failCallback) {
1670+
if (param[@"messageId"] == nil ||
1671+
param[@"type"] == nil) {
1672+
failCallback(@[[self getParamError]]);
1673+
return;
1674+
}
1675+
1676+
NSString *appKey = nil;
1677+
if (param[@"appKey"]) {
1678+
appKey = param[@"appKey"];
1679+
} else {
1680+
appKey = [JMessageHelper shareInstance].JMessageAppKey;
1681+
}
1682+
1683+
if ([param[@"type"] isEqual: @"single"] && param[@"username"] != nil) {
1684+
1685+
} else {
1686+
if ([param[@"type"] isEqual: @"group"] && param[@"groupId"] != nil) {
1687+
} else {
1688+
failCallback(@[[self getParamError]]);
1689+
return;
1690+
}
1691+
}
1692+
[self getConversationWithDictionary:param callback:^(JMSGConversation *conversation, NSError *error) {
1693+
if (error) {
1694+
failCallback(@[[error errorToDictionary]]);
1695+
return;
1696+
}
1697+
1698+
JMSGMessage *message = [conversation messageWithMessageId:param[@"messageId"]];
1699+
if (message == nil) {
1700+
failCallback(@[[self getErrorWithLog:@"cann't find this message"]]);
1701+
return;
1702+
}
1703+
1704+
if (message.contentType != kJMSGContentTypeImage) {
1705+
failCallback(@[[self getErrorWithLog:@"It is not voice message"]]);
1706+
return;
1707+
} else {
1708+
JMSGImageContent *content = (JMSGImageContent *) message.content;
1709+
[content thumbImageData:^(NSData *data, NSString *objectId, NSError *error) {
1710+
if (error) {
1711+
failCallback(@[[error errorToDictionary]]);
1712+
return;
1713+
}
1714+
1715+
JMSGMediaAbstractContent *mediaContent = (JMSGMediaAbstractContent *) message.content;
1716+
successCallback(@[@{@"messageId": message.msgId,
1717+
@"filePath": [content thumbImageLocalPath]}]);
1718+
}];
1719+
}
1720+
}];
1721+
}
1722+
16671723
RCT_EXPORT_METHOD(downloadVoiceFile:(NSDictionary *)param
16681724
successCallback:(RCTResponseSenderBlock)successCallback
16691725
failCallback:(RCTResponseSenderBlock)failCallback) {

0 commit comments

Comments
 (0)