flutter使用jmessage_flutter插件 撤销消息和下载图片问题
flutter版本 1.22.6
jmessage_flutter版本
------------------- JMessage SDK --------------------
------------- JMessage SDK version:3.9.1, build:241 ---------
------------- JCore Lib Version:2.6.2, build:169 ---------
------------- AppKey:1dfe704407e7859800890d88 ---------
问题1:撤销消息问题
这是消息发送成功时的log
| JIGUANG | D - [JMSGConversation] Action - sendMessage:optionalContent:
| JIGUANG | D - [JMSGConversation] Action - sendMessage:
| JIGUANG | D - [JMSGConversation+JMSGInner] Action - jmsg_sendMessage:<JMSGMessage, 0x60000130cc40> - [ARRAY - msgId:msgId_1619508740676408, serverMessageId:, otherSide:0001, isReceived:0, contentType:文本消息, status:消息草稿状态, fromAppKey:1dfe704407e7859800890d88, targetAppKey:1dfe704407e7859800890d88]
| JIGUANG | D - [JMessage+JMSGInner] Action - sendRequest - TCP:3
| JIGUANG | D - [JIGUANGIMController] send im request with type:jmsg_type_sendMessageSingle,rid:3923
| JIGUANG | D - [JIGUANGTcpChannelController] Action - doSendTcpRequest
| JIGUANG | D - [JMSGIMDispatchController] jcore dispatch -> version:2,uid:51125184878,rid:3923,cmd:3
| JIGUANG | D - [JMSGIMDispatchController] receive send single message response
| JIGUANG | D - [JIGUANGIMSingleMessageRequest] message server msgId - 11292514665, rid - 3923
| JIGUANG | D - [JIGUANGIMController] Request have response for type - jmsg_type_sendMessageSingle
| JIGUANG | D - [JMSGSyncMessageDBHelper] Action - insertOnlineMessageWithMsgModelArray:conversationTargetId:727239229
| JMessage | iOS | 消息发送成功:11292514665
然后撤销消息报错
flutter: retractMessage: {type: single, username: 0002, appKey: 1dfe704407e7859800890d88, messageId: 11292514665}
| JMessage | iOS | Action - handleMethodCall:: method =retractMessage
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:0002, userAppKey:1dfe704407e7859800890d88
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageWithMessageId:
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error 1, message id do not exit!, The operation couldn’t be completed. (message id do not exit! error 1.), null)
///撤销消息
opRetractMessage(msgId)async{
if(_msgtype==0){
await jMessage.retractMessage(target: JMSingle.fromJson({
'username': '0002',
'appKey': kJMAppkey
}), serverMessageId: msgId);
}else{
await jMessage.retractMessage(target: kMockGroup, serverMessageId: msgId);
}
}
上面是调用代码,msgid为消息服务器id。
问题2:下载图片问题
聊天页面发送完图片后 下载图片就会报错 如下:
| JMessage | iOS | Action - handleMethodCall:: method =downloadOriginalImage
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:0001, userAppKey:1dfe704407e7859800890d88
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageWithServerMessageId:
| JIGUANG | E - [JMSGMessageDBHelper] serverMessageId or tablename should not nil.(msgId:(null),table:message_table_626D4F10A38FC697FBB962B341314)
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error 1, cann't find this message!, The operation couldn’t be completed. (cann't find this message! error 1.), null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
#3 JmessageFlutter.downloadOriginalImage (package:jmessage_flutter/jmessage_flutter.dart:1199:34)
#4 _ChatPageState.opDownImage (package:tyoa/chat/chat.dart:981:22)
#5 _ChatPageState.opPopMenu (package:tyoa/chat/chat.dart:960:9)
#6 _ChatPageState._getMessageList. (package:tyoa/chat/chat.dart:200:23)
#7 _WPopupMenuState.onTap. (package:tyoa/widget/popupmenu.dart:106:27)
#8 _rootRunUnary (dart:async/zone.dart:1198:47)
#9 _CustomZon<…>
退出了聊天页面
| JMessage | iOS | Action - handleMethodCall:: method =getConversations
| JIGUANG | D - [JMSGConversation] Action - allConversations:
| JMessage | iOS | Action - handleMethodCall:: method =getHistoryMessages
flutter: add listener receive ReceiveMessage
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:0001, userAppKey:1dfe704407e7859800890d88
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageArrayFromNewestWithOffset::
再次进入到之前那个聊天页面,下载图片成功
| JMessage | iOS | Action - handleMethodCall:: method =downloadOriginalImage
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:0001, userAppKey:1dfe704407e7859800890d88
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageWithMessageId:
| JIGUANG | D - [JMSGImageContent] Action - largeImageDataWithProgress::
flutter: 下载图片--回调-1
flutter: 图片消息,filePath = /Users/weaponchen/Library/Developer/CoreSimulator/Devices/37577265-D71E-42DD-86E3-C569C9616630/data/Containers/Data/Application/951347E0-4DC3-483A-8F5A-079B8602DA3C/Documents/0002_727244356/0001_single_1dfe704407e7859800890d88/sendPath/image/53290-03-05/large/5B9FA0B44931095CBA5AA1D00C26D6CC.jpg
flutter: 图片消息,messageId = msgId_1619508286379706
flutter: 下载图片--回调-2
///下载图片
opDownImage(msgId)async{
if(_msgtype==0){
await jMessage.downloadOriginalImage(target: JMSingle.fromJson({
'username': '0001',
'appKey': kJMAppkey
}), messageId: msgId).then((value){
print('下载图片--回调-1');
print('图片消息,filePath = ' + value['filePath']);
print('图片消息,messageId = ' + value['messageId'].toString());
print('下载图片--回调-2');
});
}else{
await jMessage.downloadOriginalImage(target: kMockGroup, messageId: msgId).then((value){
print('下载图片--回调-1');
print('图片消息,filePath = ' + value['filePath']);
print('图片消息,messageId = ' + value['messageId'].toString());
print('下载图片--回调-2');
});
}
以上是下载图片代码,msgid为消息id