Getstream firebase auth-react本机文档



不确定是否有人对getstream和react native有任何经验。

我遵循了那里的教程,在我现有的应用程序中实现了getstreams SDK,它运行得很好,但我被代币卡住了。我已经成功地设置了firebase,所以当新用户注册时,我可以在firebase auth和getstream上看到UID和信息,但我在前端挂断了让用户使用那里的令牌登录聊天。我在那里扩建了一个防火基地,但仍然存在问题。与dev.tokens配合使用效果很好,但就是无法通过这一部分。有没有更好的例子或文档?非常感谢。

只有我能找到的文件。。不特定于本地反应https://getstream.io/chat/docs/react/tokens_and_authentication/

这是我当前初始化用户的方式。。用户令牌在我的聊天配置文件中进行了硬编码。

// useChatClient.js
import { useEffect, useState } from 'react';
import { StreamChat } from 'stream-chat';
import { chatApiKey, chatUserId, chatUserName, chatUserToken } from './chatConfig';
const user = {
id: chatUserId,
name: chatUserName,
};
const chatClient = StreamChat.getInstance(chatApiKey);
export const useChatClient = () => {
const [clientIsReady, setClientIsReady] = useState(false);
useEffect(() => {
const setupClient = async () => {
try {
chatClient.connectUser(user, chatUserToken);
setClientIsReady(true);
// connectUser is an async function. So you can choose to await for it or not depending on your use case (e.g. to show custom loading indicator)
// But in case you need the chat to load from offline storage first then you should render chat components
// immediately after calling `connectUser()`.
// BUT ITS NECESSARY TO CALL connectUser FIRST IN ANY CASE.
} catch (error) {
if (error instanceof Error) {
console.error(`An error occurred while connecting the user: ${error.message}`);
}
}
};
// If the chat client has a value in the field `userID`, a user is already connected
// and we can skip trying to connect the user again.
if (!chatClient.userID) {
setupClient();
}
}, []);
return {
clientIsReady,
};
};

下一步是从Firebase云函数(ext-auth-chat-getStreamUserToken(请求令牌,然后用该令牌初始化当前用户。

有一个指南和视频展示了如何使用流式聊天Flutter SDK:来做到这一点

  • https://getstream.io/chat/docs/sdk/flutter/guides/token_generation_with_firebase/
  • https://youtu.be/Dt_taxX98sg

最新更新