Flutter Android JMessage downloadThumbImage 报错

标签: #<Tag:0x00007f6583491cc8>

机型:Redmi 5
版本:Android 8.1.0 (API 27)
问题描述:Android下载缩略图时报错,IOS版本同样的代码是正常的。文档里参数target描述的不是很清楚,看java代码应该是有type和username就可以了,试了几种target,android都是报同样的错误,ios可以正常获取到图片。另外downloadVoiceFile也有同样的错误。
代码: final JMSingle kMockUser = JMSingle.fromJson({
‘username’: ‘gaohong’,
‘appKey’: ‘285e5d42757ef682045537c4’,
});
Map resJson = await _jmessage.downloadThumbImage(
target: target,
messageId: messageId,
);
日志:E/flutter ( 4471): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(3, No such message, )
E/flutter ( 4471): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter ( 4471): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter ( 4471):
E/flutter ( 4471): #2 JmessageFlutter.downloadThumbImage (package:jmessage_flutter/jmessage_flutter.dart:1066:34)

你的 type 传对了吗,再就是你用的插件的版本是否是最新的?

type是对的,JMSingle,版本是0.1.0

找到原因了,是messageId传错了,用的本地的id,应该用serverMessageId。非常感谢~

1赞

补充一点,ios下传的messageId要是本地的id…这里能否统一一下?

遇到这个问题的时候,你下载缩略图的是 消息发送方还是接收方?

遇到这个问题时是发送方。

你给下你测试的日志吧,就是 iOS 端获取到的这个 serverID,你说的本地ID,以及分别用这两个ID去获取的返回结果。

IOS使用id
flutter: messageId: msgId_1565834474708165
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:gaohong, userAppKey:285e5d42757ef682045537c4
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageWithMessageId:
| JIGUANG | D - [JMSGImageContent] Action - thumbImageData:

IOS使用serverMessageId
flutter: messageId: 4474708165
| JIGUANG | D - [JMSGConversation] Action - createSingleConversationWithUsername,username:gaohong, userAppKey:285e5d42757ef682045537c4
| JIGUANG | D - [JMSGConversation] The conversation already exists. Return directly.
| JIGUANG | D - [JMSGConversation] Action - messageWithMessageId:
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(Error 1, cann’t find this message!, The operation couldn’t be completed. (cann’t find this message! error 1.))
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)

#2 JmessageFlutter.downloadThumbImage (package:jmessage_flutter/jmessage_flutter.dart:1066:34)

#3 _ChatState._downloadThumbImage (package:yqw_flutter/pages/chat.dart:163:37)

#4 _ChatState.getHistory (package:yqw_flutter/pages/chat.dart:79:31)

#5 _ChatState.initState (package:yqw_flutter/pages/chat.dart:42:5)
#6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4033:58)
#7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
#8 Element.inflateWidge<…>