Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bugs that occur in various situations when receiving messages #191

Open
BeiJiu123 opened this issue Dec 31, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@BeiJiu123
Copy link

BeiJiu123 commented Dec 31, 2024

Describe the bug
When I send messages to the mobile end through the web, the app is in an unopened state. No matter how many messages the web end sends, when the mobile end opens, only one message is displayed

配置代码
Future initOpenIM() async {

var apath = (await getApplicationDocumentsDirectory()).path;

await OpenIM.iMManager.initSDK(
  platformID: Platform.isIOS ? 1 : 2,
  // apiAddr: 'https://im.youyangai.com/api',
  // wsAddr: 'wss://im.youyangai.com/msg_gateway',
  apiAddr: "https://im.youyangai.com/api/",
  wsAddr: "wss://im.youyangai.com/msg_gateway",
  // dataDir: cachePath,
  logLevel: 6,
  logFilePath: apath,

  listener: OnConnectListener(
    onConnecting: () {
      print('onConnecting......');
    },
    onConnectFailed: (code, error) {
      print('onConnectFailed...... $error');
    },
    onConnectSuccess: () {
      print('onConnectSuccess......');
    },
    onKickedOffline: () {
      print('onKickedOffline......');
    },
    onUserTokenExpired: () {
      print('onUserTokenExpired......');
    },
  ),
  dataDir: apath,
);
int? status = await OpenIM.iMManager.getLoginStatus();

if (status != 3) {
  try {
    var userDataString = await SharedPreferencesManager.read('loginData');
    if (userDataString != null) {
      final userData = json.decode(userDataString);
      await OpenIM.iMManager
          .login(userID: userData['userId'], token: userData['imToken']);

    }
  } catch (e) {
    // 处理 jsonDecode 抛出的异常或其他错误
    print('An error occurred while decoding userData: $e');
  }
}
OpenIM.iMManager
  ..userManager.setUserListener(OnUserListener())
  ..messageManager.setAdvancedMsgListener(OnAdvancedMsgListener(
    onMsgDeleted: (Message msg) {
      debugPrint('onMsgDeleted');
    },
    onNewRecvMessageRevoked: (RevokedInfo info) {
      debugPrint('onNewRecvMessageRevoked');
    },
    onRecvC2CReadReceipt: (List<ReadReceiptInfo> list) {
      debugPrint('onRecvC2CReadReceipt');
    },

    onRecvNewMessage: (Message msg) async {
      final chat = Provider.of<ChatStore>(context, listen: false);
      List<ConversationInfo> list = await OpenIM
          .iMManager.conversationManager
          .getAllConversationList();
      chat.setConversationList(list);
      if (msg.sessionType == 1&&chat.conversationInfo.conversationType==1&&msg.sendID==chat.conversationInfo.userID) {
        chat.messageList.add(msg);
      } else if(msg.sessionType == 3&&chat.conversationInfo.conversationType==3&&msg.groupID==chat.conversationInfo.groupID) {
        chat.messageList.add(msg);
      }
      chat.setMessageList(chat.messageList);
    },
    onRecvOfflineNewMessage: (Message msg) {
      debugPrint('onRecvOfflineNewMessage');
    },
    onRecvOnlineOnlyMessage: (Message msg) {
      debugPrint('onRecvOnlineOnlyMessage');
    },
  ))

// Set up message sending progress listener
  ..messageManager.setMsgSendProgressListener(OnMsgSendProgressListener())

// Set up friend relationship listener
  ..friendshipManager.setFriendshipListener(OnFriendshipListener())

// Set up conversation listener
  ..conversationManager.setConversationListener(OnConversationListener())

// Set up group listener
  ..groupManager.setGroupListener(OnGroupListener());

}
Get contact list
getList() async {
final chat = Provider.of(context, listen: false);
int? status = await OpenIM.iMManager.getLoginStatus();
if(status!=3){
Navigator.popAndPushNamed(context, Routes.login);
}
List list = await OpenIM.iMManager.conversationManager
.getAllConversationList()
;
chat.setConversationList(list);
}
Retrieve local chat records
SearchResult result = await OpenIM.iMManager.messageManager
.searchLocalMessages(
conversationID: conversationID,
messageTypeList: [101, 102, 103, 104, 105],
keywordList: [],
searchTimePosition: 0,
searchTimePeriod: 0,
pageIndex: pageIndex,
count: 30);

Steps to reproduce the behavior:

  1. 将模拟器上的设备关闭,react项目 web端发送消息
  2. 打开手机,到达获取最近联系人列表
  3. 即使发送了多条消息也只有一条未读image
    image
    4.查看消息列表也只有一条

Version information

  • Device: e.g. iPhone 15pro
  • OS: e.g. iOS 17.2
  • Package Version: e.g. v3.8.2+1
  • Flutter Version: e.g. v3.24.5
@BeiJiu123 BeiJiu123 added the bug Something isn't working label Dec 31, 2024
@std-s
Copy link
Member

std-s commented Jan 2, 2025

Hi, you can use the Demo experiment.

@BeiJiu123
Copy link
Author

Hi, you can use the Demo experiment.

The problem still exists when using the demo, and another issue is that the speed of obtaining chat records is very slow
image
image

@std-s
Copy link
Member

std-s commented Jan 6, 2025

If you stay in the chat scene, you can retrieve the message history when you enter the foreground from the background, or retrieve the message history in reverse.

@BeiJiu123
Copy link
Author

If you stay in the chat scene, you can retrieve the message history when you enter the foreground from the background, or retrieve the message history in reverse.If you stay in the chat scene, you can retrieve the message history when you enter the foreground from the background, or retrieve the message history in reverse.如果停留在聊天场景中,可以从后台进入前台时检索消息历史记录,也可以反向检索消息历史记录。

Firstly, when I went to retrieve the conversation list, there were clearly seven unread messages, but only one. Then when I entered the chat, the only chat record I checked was this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants