我已经使用其设置正确初始化了 CometChatApp,如下面的代码所示:
AppSettings appSettings = (AppSettingsBuilder()
..subscriptionType = CometChatSubscriptionType.allUsers
..region = Env.cometChatRegion
..autoEstablishSocketConnection = true)
.build();
CometChat.init(Env.cometChatAppId, appSettings,
onSuccess: (String successMessage) {
debugPrint(
"CometChat initialization completed successfully $successMessage");
}, onError: (CometChatException excep) {
debugPrint(
"CometChat initialization failed with exception: ${excep.message}");
});
然后为 Flutter 添加了 UIKitSettings 和 CometChatUiKit init 方法,如文档中所述:Flutter UiKit V4 的集成,代码如下:
UIKitSettings uiKitSettings = (UIKitSettingsBuilder()
..subscriptionType = CometChatSubscriptionType.allUsers
..autoEstablishSocketConnection = true
..region = Env.cometChatRegion
..appId = Env.cometChatAppId
..authKey = Env.cometChatAuthKey
..extensions = CometChatUIKitChatExtensions.getDefaultExtensions())
.build();
CometChatUIKit.init(
uiKitSettings: uiKitSettings,
onSuccess: (String successMessage) {
debugPrint(
"CometChatUIKit initialization completed successfully $successMessage");
},
onError: (CometChatException e) {
debugPrint(
"CometChatUIKit initialization failed with exception: ${e.message}");
});
消息传递部分工作完美,我可以毫无问题地在用户之间发送和接收消息(文本和媒体)。但是当我按照文档中所述添加适用于 Flutter 的 CallUiKit 时(这基本上与添加此行的 UiKit 方法相同):
..callingExtension = CometChatCallingExtension()
)
我希望看到这种行为,正如医生所说:
我也尝试添加 Flutter SDK(聊天和通话)中的 init 方法,尽管我只对使用 FlutterUiKit 库感兴趣,但我尝试使用文档建议的旧 flutter SDK,并且也搞乱了代码。到目前为止,没有任何效果。聊天和通话 UI 工具包成功初始化后,通话按钮将添加到 CometChatMessageHeader 的 appBarOptions 中。这将允许用户向其他聊天参与者发起语音或视频呼叫。除了呼叫按钮之外,呼叫 UI 套件还为来电、去电和正在进行的呼叫提供功能齐全的 UI 组件。 但我没有看到 AppBar 中出现 按钮,只有默认的 ProfileInfo 按钮。
PS:我也正确添加了我的 puspec.yaml 文件中的依赖项:
cometchat_chat_uikit: ^4.0.0-beta.2
cometchat_sdk: ^4.0.0-beta1
cometchat_calls_uikit: ^4.0.0-beta.1
..callingExtension = CometChatCallingExtension()
..extensions = CometChatUIKitChatExtensions.getDefaultExtensions()