zego_zim 2.5.0 zego_zim: ^2.5.0 copied to clipboard
ZEGO ZIM Flutter SDK is a flutter plugin wrapper based on ZIM native Android / iOS SDK.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zego_zim/zego_zim.dart';
import 'package:zego_zim_example/topics/chat/chat_with_conversation/group/group_chat_page.dart';
import 'package:zego_zim_example/topics/chat/chat_with_conversation/group/group_set_page/group_set_page.dart';
import 'package:zego_zim_example/topics/chat/chat_with_conversation/peer/peer_chat_page.dart';
import 'package:zego_zim_example/topics/login/user_model.dart';
import 'dart:async';
import 'package:zego_zim_example/topics/splash/splash_page.dart';
Future<void> main() async {
ZIMEventHandler.onReceivePeerMessage = (zim, messageList, fromUserID) async{
log("message");
ZIM.getInstance()!.sendMessageReceiptsRead(messageList, fromUserID, ZIMConversationType.group);
// ZIM.getInstance()!.sendConversationMessageReceiptRead(fromUserID, ZIMConversationType.peer).then((value){
// log('1');
// }).catchError((onError){
// log('1');
// });
};
ZIMEventHandler.onMessageReceiptChanged = (zim, infos) {
// 对方设置了消息的已读回执
log("message");
};
ZIMEventHandler.onConversationMessageReceiptChanged = (zim, infos) {
// 对方设置会话的已读回执
log("message");
};
ZIMEventHandler.onMessageRevokeReceived = (ZIM zim, List<ZIMRevokeMessage> messageList) {
log("message");
};
// ZIMGroupMessageReceiptMemberQueryConfig config =
// ZIMGroupMessageReceiptMemberQueryConfig();
// ZIM
// .getInstance()!
// .queryGroupMessageReceiptUnreadMemberList(message, groupID, config)
// .then((result) {
// // 查询到对应的成员列表
// })
// .catchError((onError) {
// });
// ZIMTextMessage message = ZIMTextMessage(message: "test");
// ZIMMessageSendConfig sendConfig = ZIMMessageSendConfig();
// sendConfig.hasReceipt = true; //设置消息带回执
// ZIM
// .getInstance()!
// .sendMessage(
// message, conversationID, ZIMConversationType.peer, sendConfig)
// .then((result) {
// // 这里表示发送消息成功,message 的 receiptStatus 会为 PROCESSING,业务层可根据这个标志展示回执中的逻辑。
// }).catchError((onError) {});
// List<ZIMMessage> messages = [];
// ZIM
// .getInstance()!
// .sendMessageReceiptsRead(
// messages, conversationID, ZIMConversationType.peer)
// .then((result) {
// // 消息已读的回调
// }).catchError((onError) {});
// ZIM
// .getInstance()!
// .sendConversationMessageReceiptRead(
// conversationID, ZIMConversationType.peer)
// .then((value) {
// // 会话已读成功,开发者可通过监听这个回调,把这个会话内对方发的消息都设置为已读的标志。
// }).catchError((onError) {});
// ZIM
// .getInstance()!
// .queryMessageReceiptsInfo(
// messages, conversationID, ZIMConversationType.peer)
// .then((value) {
// // 查询到这一批消息的状态和数量,遍历 infos 获取对应的消息 ID 和 count
// }).catchError((onError) {});
runApp(MaterialApp(
title: 'ZIM',
debugShowCheckedModeBanner: false,
home: //GroupSetPage()
SplashPage(),
navigatorObservers: [UserModel.shared().routeObserver],
));
}