How to check if user already signed in to another device (via Google Play Services)?

Hi guys,

As the title says, is there a way for me to check if the same user is signed in to a different device? For example, user download app on device A, sign in, and then download app on device B and sign in. At device B, I would like to check (using Google Play Services) if the same user has already signed in to another device.

I’m using this code to sign in:

Social.localUser.Authenticate((bool success) =>{
//do stuff if success else ...
});

Thanks.

do you find your anwser ? ^^
Need it too!

Have a good day!:slight_smile:

I know you can get a list of the devices (if your application is allowed access that is). But not the list of active devices.

Active devices would require some sort of signaling of session activity. Usually you login, start a session, and that is indefinite until otherwise told to close the sesssion or a timeout. To have more granular data you’d have to be habitually communicating activity… I doubt Google does this.

How apps like Netflix and the sort do it is that you’re actively communicating with the server during a stream. So it makes sense to track that activity. So thusly it knows.

This also goes for online games. You’re actively talking to the server.

If you need this for you online game, just associate a unique identifier with each device (a session token as a guid is usually enough). And every communication you actively track who is communicating. If you have 2 different tokens communicating on the same account at roughly the same time (within minutes of each other), then you know you have 2 devices connected simultaneously.

Note, this may occur if someone puts down a device and picks up another. You should filter out the idea of token A swapping for token B. But instead check for token A, then token B, and then a return to token A.

Of course it’s also always good to send an ‘end-session’ token on exit of the game. But this isn’t a guarantee… what if they loss internet connection, their phone died, or they just put the app to sleep. Hence the need for session timeouts.

Thanks @lordofduct ! You had give to me a very good idea to prevent using multiple device or account in same time without server just with GoogleService, I explain if someone is interested .

I will add in a GoogleSave a int “x”

When I connect i will generate randomly a int 0-1000 , save it as x in my GoogleSave.

Every time i want to check if someone else is connecting on this account i’ll load the GoogleSave and check X.

if X == what I had generated , no one else try to connect.
if X != , Someone connected, I disconnect immediatly.

And on the contrary, if i connect when someone else is connected , he will be disconnected because i’ll load a new X