Issue Description:
Users are experiencing an issue where the fetchUserInfoById method in the React Native Chat SDK consistently returns an empty Map, even when invoked with correct user IDs. This prevents user information from being properly displayed in conversation histories.
Platform/SDK:
React Native Chat SDK
Step by Step Solution:
1. Verify User Registration:
- Confirm that the user IDs being used are correctly registered with Agora Chat. This involves using RESTful APIs to create a username entry and calling the updateOwnUserInfo API to update the user's properties.
2. Use RESTful API as Alternative:
- If the issue persists, consider using the RESTful API method to retrieve user info as an alternative. Confirm that the correct user attributes are returned.
3. Conversation Type Check:
- Ensure that you're extracting usernames correctly depending on the conversation type (one-to-one). The getAllConversations() output comprises conversation IDs, which are not the same as usernames.
4. Fetch User Info:
- For one-to-one conversations, identify the peer chat's conversationID, call getConversation(), search for the latest message ID, and extract the "to" attribute. Use this attribute value with fetchUserInfoById.
5. Error Handling:
- Try to catch any errors that might be thrown when calling fetchUserInfoById and debug accordingly for additional insights.
Root Cause:
The method fetchUserInfoById is being called with conversation IDs instead of the required usernames. This discrepancy causes the method to return an empty map because the expected input is not provided.
Prevention/Best Practice:
- Ensure all user IDs are properly registered and updated with attributes using RESTful APIs before calling fetchUserInfoById.
- Familiarize with the specific workflow for conversation types within Agora Chat to properly utilize SDK methods.
Corresponding Document/Link:
- Agora Chat SDK documentation for retrieving user attributes: Retrieve User Attributes in React Native
- Agora Chat Client API: GitHub Sample ContactInfo.tsx