stream-chat-react-native
stream-chat-react-native copied to clipboard
[🐛] 🔥 Cannot switch from anonymous to authenticated or vice versa
Issue
On a live activity channel
- I would like to create a public anonymous chat that people can view as anonymous users.
- If they are anonymous, they can log in, and
<MessageInput />
will be available so they can comment - If they are authenticated, sign out and become anonymous.
<MessageInput />
will disappear.
In both cases, they should be able to see the channel contents.
It seems like this is not possible and results in this message: "Error loading messages for this channel"
Steps to reproduce
Steps to reproduce the behavior:
I've tried a few ways to switch the user from authenticated to anonymous:
Simple:
const logout = async () => {
await chatClient?.disconnectUser();
await chatClient?.connectAnonymousUser();
};
Clear out everything:
if (!chatClient) throw new Error("No valid chat client found");
if (!channel) throw new Error("No valid channel found");
await channel?.stopWatching();
await chatClient.disconnectUser();
await chatClient.connectAnonymousUser();
await watchChannel(chatClient);
The code is roughly the same going from authed to non-authed or vice versa; I've only included converting to anonymous for brevity.
Expected behavior
I would like the app to be able to seamlessly transition between an anonymous and authed state.
Project Related Information
Expo SDK 51
Customization
<OverlayProvider
value={{
style: getTheme(),
}}
>
<ThemeProvider>
<Chat client={chatClient} enableOfflineSupport={false}>
<Channel
channel={channel}
deletedMessagesVisibilityType="never"
SendMessageDisallowedIndicator={() => null}
>
<MessageList />
<MessageInput />
</Channel>
</Chat>
</ThemeProvider>
</OverlayProvider>
Offline support
- [ ] I have enabled offline support.
- [ ] The feature I'm having does not occur when offline support is disabled. (stripe out if not applicable)
Environment
Click To Expand
package.json
:
{
"stream-chat-expo": "^5.31.1",
}
react-native info
output:
CLI command not found
-
Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [X] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
-
stream-chat-react-native (note: this is for expo, but likely occurs on
stream-chat-react-native` too ) version you're using that has this issue:-
^5.31.1
-
- Device/Emulator info:
- [ ] I am using a physical device
- OS version:
e.g. iOS 17.5
- Device/Emulator:
e.g. iPhone 15 pro
Additional context
Screenshots
Please note, that I am not calling connect multiple times. I think that rapidly disconnecting and re-connecting causes this error.