AgoraIO-Extensions / agora-rtc-react

Agora RTC React SDK
https://agoraio-extensions.github.io/agora-rtc-react/
MIT License
31 stars 11 forks source link

useRemoteUsers returns empty array #183

Closed azm3n closed 10 months ago

azm3n commented 10 months ago

What kind of problem do you need help?

I use agora in a React web app and a Flutter mobile app. When I join a channel on the website and mobile app only on mobile, I can see and hear the customer from a different device. I tried to fix it and found that useRemoteUsers does not return any client. What could be the reasons for this behavior?

I am using agora-rtc-react version 2.1.0 and it is code for React that I was taking inspiration from https://codesandbox.io/p/sandbox/agora-rtc-react-quickstart-rdpc46

guoxianzhe commented 10 months ago

@Azm3n useRemoteUsers hooks only return users data when :

https://github.com/AgoraIO-Extensions/agora-rtc-react/blob/main/packages/agora-rtc-react/src/hooks/useRemoteUsers.ts#L11

azm3n commented 10 months ago

I completely understand it. I haven't changed anything from mobile flow because when I was using agora-rtc-react < 2.0.0 it was working. When I decided to change versions I started using useRemoteUsers and even though the flow from mobile app hasn't changed it is not returning expected mobile user in React app. Are there any other ways to retrieve remote clients?

guoxianzhe commented 10 months ago

@Azm3n You can use useClientEvent to retrieve remote clients by yourself.

eg:

const client = useRTCClient();
useClientEvent(client,'user-published',(user)=>{
    console.log('user:',user)
})

@Azm3n I noticed you are trying to communicating with mobile app, is this mobile app are using our Agora RTC SDK? If yes, please check your two platform's uid is same data type.

azm3n commented 10 months ago

It was all about uid. React app was sending string type and mobile app was sending number. Thank you!!