首页 > 解决方案 > 跨平台(iOS 和 Android)聊天不适用于 chat21 SDK

问题描述

我们正在为 android 和 iOS 使用 chat-SDK chat21。

https://github.com/chat21/chat21-ios-demo

https://github.com/chat21/chat21-android-sdk

在我的 firebase 帐户下,我有 2 个应用程序 1 用于 android 和另一个用于 iOS。

对于 Android,我们使用google-service.json带有App ID.

对于 iOS,我们使用GoogleService-info.plist文件配置 chat21 SDK

但是,当我从 android 发送消息时,iOS 没有收到任何消息,这与从 iOS 到 android 应用程序发生的事情相同。

是因为我们使用不同的应用程序吗?(项目设置->您的应用程序部分)尽管 App ID 仅在 android 应用程序中使用,但两者都有不同的 App ID。

内部聊天我的意思是 iOS 到 iOS 和 android 到 android 聊天工作非常好,跨平台聊天不起作用。

在此处输入图像描述

在此处输入图像描述

如果我在配置中缺少某些东西,请告诉我,以便快速修复谢谢

7 月 2 日更新

在此处输入图像描述

FirebaseDatabase.getInstance().setPersistenceEnabled(true);

ChatManager.startWithEmailAndPassword(this, [APP_ID],
[YOUR_EMAIL], [YOUR_PASSWORD], new ChatAuthentication.OnChatLoginCallback() {
@override
public void onChatLoginSuccess(IChatUser currentUser) {
ChatManager.getInstance().createContactFor(currentUser.getId(), currentUser.getEmail(),
[YOUR_FIRST_NAME], [YOUR_LAST_NAME], new OnContactCreatedCallback() {
@override
public void onContactCreatedSuccess(ChatRuntimeException exception) {
if (exception == null) {
ChatUI.getInstance().openConversationsListActivity();
} else {
// TODO: handle the exception
}
}
});
}

@override
public void onChatLoginError(Exception e) {
// TODO: 22/02/18
}
}); 

上面的 android 代码使用 app id 与 firebase 连接,并在 iOS 中从 plist 文件中获取 app_id。两个 APP_Id 都不同。

标签: androidiosfirebasefirebase-realtime-databasechatsdk

解决方案


通过替换APP_ID"chat"(iOS 树的同名)。以前,我使用的是 Firebase APP_ID,它指的是 Firebase。这是我的应用程序的租户名称,并且对于使用 chat 的所有客户端都必须相同。这解决了问题!感谢团队!


推荐阅读