openim-sdk-core icon indicating copy to clipboard operation
openim-sdk-core copied to clipboard

Sending image messages fails for flutter ios

Open script-2000 opened this issue 2 years ago • 15 comments

What happened?

We are having some issues whereby sending images fails for flutter IOS but works for Android.

What did you expect to happen?

we expected the image to be send to the recipient of the chat.

How can we reproduce it (as minimally and precisely as possible)?

 Message message =
          await OpenIM.iMManager.messageManager.createImageMessageFromFullPath(
              // imagePath: "{}",
              imagePath: image.path);
var apath = (await getApplicationDocumentsDirectory()).path;
  final success = await OpenIM.iMManager.initSDK(
    platformID: Platform.isIOS ? 1 : 2,
    apiAddr: 'https://gallics.app:8443/chat',
    wsAddr: 'wss://gallics.app:8443/chat/msg_gateway',
    dataDir: apath, // 数据存储路径。如:
    objectStorage: 'cos', // 图片服务器默认'cos'
    logLevel: 6, // 日志等级,默认值6
    listener: OnConnectListener(
      onConnectSuccess: () {
        // 已经成功连接到服务器
      },
      onConnecting: () {
        // 正在连接到服务器,适合在 UI 上展示“正在连接”状态。
      },
      onConnectFailed: (code, errorMsg) {
        // 连接服务器失败,可以提示用户当前网络连接不可用
      },
      onKickedOffline: () {
        // 当前用户被踢下线,此时可以 UI 提示用户“您已经在其他端登录了当前账号,是否重新登录?”
      },
    ),
  );

Anything else we need to know?

we used image_picker-1.0.4 which can be found on pub to get our images from Ios and Andriod , and then pass the path to openIM.

https://pub.dev/packages/image_picker

version

$ flutter_openim_sdk: ^3.3.0 $ flutter 3.13.9

Cloud provider

OS version

$ IOS version 15 and above

Install tools

script-2000 avatar Nov 02 '23 10:11 script-2000

@script-neutron hi, Is there more exception information? Start with the call to "createImageMessageFromFullPath".

std-s avatar Nov 02 '23 10:11 std-s

not really any more exceptions , i added the only available message

script-2000 avatar Nov 02 '23 10:11 script-2000

any update ?

script-2000 avatar Nov 03 '23 06:11 script-2000

  1. what version of SDK are you using?
  2. Can you go to the sandbox and see if this file really exists?
  3. All logs that call "createImageMessageFromFullPath" to send messages will be copied here.

std-s avatar Nov 03 '23 08:11 std-s

SDK 3.3.0

[open_im_sdk/util.go:247]       input req       {"operationID": "1699005205439", "function name": "github.com/openimsdk/openim-sdk-core/v3/internal/conversation_msg.(*Conversation).CreateImageMessageFromFullPath-fm", "args": ["/private/var/mobile/Containers/Data/Application/7745E110-07AA-491A-B6DB-1960C5FE9C31/tmp/image_picker_0660E814-E41E-4E89-8FD5-358EF6285908-58964-0000181BD5432AFF.jpg"]}
fnv: 0x1007850a0 ins: [<*context.valueCtx Value> /private/var/mobile/Containers/Data/Application/7745E110-07AA-491A-B6DB-1960C5FE9C31/tmp/image_picker_0660E814-E41E-4E89-8FD5-358EF6285908-58964-0000181BD5432AFF.jpg]
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: FormatException: Unexpected end of input (at character 1)


^


#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
openimsdk/open-im-server#1      _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:501:7)
openimsdk/open-im-server#2      _parseJson (dart:convert-patch/convert_patch.dart:36:10)
openimsdk/open-im-server#3      JsonDecoder.convert (dart:convert/json.dart:610:36)
openimsdk/open-im-server#4      JsonCodec.decode (dart:convert/json.dart:216:41)
openimsdk/open-im-server#5      jsonDecode (dart:convert/json.dart:155:10)
openimsdk/open-im-server#6      Utils.formatJson (package:flutter_openim_sdk/src/utils.dart:12:46)
openimsdk/open-im-server#7      Utils.toObj (package:flutter_openim_sdk/src/utils.dart:8:9)
openimsdk/open-im-server#8      MessageManager.createImageMessageFromFullPath.<anonymous closure> (package:flutter_openim_sdk/src/manager/im_message_manager.dart:232:34)
<asynchronous suspension>

script-2000 avatar Nov 03 '23 09:11 script-2000

Will the demo run correctly on your iPhone? And use Flutter SDK 3.7.12

https://github.com/openimsdk/open-im-flutter-demo

std-s avatar Nov 03 '23 11:11 std-s

ok am going to try and see

script-2000 avatar Nov 05 '23 12:11 script-2000

I have the same question, any update ?

abel-wang-git avatar Dec 06 '23 03:12 abel-wang-git

@script-neutron @abel-wang-git hi, "dataDir: apath," this input parameter needs to end with "/". like this: "dataDir: xx/xx/"

std-s avatar Dec 08 '23 08:12 std-s

/invite

cubxxw avatar Feb 08 '24 05:02 cubxxw

The latest version doesn't have this issue. Please go ahead and use it.

skiffer-git avatar Nov 21 '24 12:11 skiffer-git