User Presence and Activity not set to Offline after signing out or closing App

Most of the times when a user closes the App, their activity and presence are automatically set to OFFLINE, which allows me to display the proper information in game, but every once in a while a player who does disconnect doesn’t do it. How does the Friend Service determine when a player goes offline? How could I force a change on the player’s presence on logout or app closing to ensure they properly set their presence and activity?

What if the player shuts down their phone while in the app? Which functions are called from the Unity Runtime at that moment that I could use to change the player’s presence and activity?

I’m seeing this issue as well. When the user quits abruptly or if the game crashes, they stay online forever.

You can just set the presence to Offline on the OnApplicationQuit callback.
But if the user lose connection or quit abruptly (callback not called) nothing prevent the status from remaining unchanged, you could deal with it by reading the last modification date of the status so you can assert real status or display something like “was connected xx hours ago”

Hi,

As mentioned by @KevinCastejon , the friends service will automatically detect things like application crashes or weird network related lost of connectivity however if you are exiting the game normally the best practice is to make a call to set your presence to OFFLINE on application quit.

If you have some sort of handler related to closing the application try and make the call to SetPresence in there.

Do you know why the friends service does not automatically set presence to OFFLINE when logging out from AuthenticationService ?

It was never hooked up to the Authentication Services callbacks it could be a valid feature request though, for future releases.

1 Like

When a friend stays “Online” indefinitely, their LastSeen value is set January 1, 0001. For anyone online, their LastSeen is set to that value as well. This means there is no way to determine if the friend is actually still online.