react-native-agora icon indicating copy to clipboard operation
react-native-agora copied to clipboard

Different callback time with Android & iOS when UserOffline event fired

Open giftsets opened this issue 4 years ago • 5 comments

Hello,

In the Agora for React-Native documentation, the 'UserOffline' event is defined as follows.

=====================================================================================

UserOffline UserOffline: UserOfflineCallback Occurs when a remote user (Communication)/host (LiveBroadcasting) leaves the channel.

There are two reasons for users to become offline:

Leave the channel: When the user/host leaves the channel, the user/host sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel. Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the Communication profile, and more for the LiveBroadcasting profile), the SDK assumes that the user/host drops offline. A poor network connection may lead to false detections, so we recommend using the Agora RTM SDK for reliable offline detection.

=====================================================================================

I tested each other's calls using an Android device and an iOS device.

When an iOS device app is killed while on a call, the 'UserOffline' event is immediately called on the Android device. However, when an Android device app is killed while on a call, the 'UserOffline' event is called on the iOS device after about 20 seconds.

Why is the time for receiving the 'UserOffline' event different when I do the same thing that kills the app?

I would like to receive the 'UserOffline' event immediately. Is there any way?

thank you.

giftsets avatar Nov 17 '21 05:11 giftsets

will wait for the socket disconnnected if you kill the application.

LichKing-2234 avatar Nov 17 '21 06:11 LichKing-2234

@LichKing-2234 What I am curious about is why the socket disconnection time is different between Android and iOS. Could you tell me why?

giftsets avatar Nov 17 '21 07:11 giftsets

Because we disconnect the socket after receiving the applicationWillTerminate event on iOS.

LichKing-2234 avatar Nov 17 '21 07:11 LichKing-2234

@LichKing-2234 thank you very much. So, doesn't an event like applicationWillTerminate happen in Android?

giftsets avatar Nov 17 '21 07:11 giftsets

https://newbedev.com/android-ondestroy-or-similar-method-in-application-class

LichKing-2234 avatar Nov 17 '21 09:11 LichKing-2234