Sign In Register

How can we help you today?

Start a new topic

Game Center active on multiple devices


I was wondering what is the best way to detect when the same Game Center account becomes active on a different device at the same time.

Is there a way to query if multiple connections are active and send a message to other devices?



Hey Helena,

You can check if the player is online in the AuthenticationResponse script using...

if(Spark.getPlayer() != null &&  Spark.getPlayer().isOnline())
    // send message here

This should work for you.



I thought about that function. However, you have to be authenticated to query it. 

If device 2 authenticates, surely that flag will be on because of him and not because of device 1's authentication right?

Would you recommend doing a deviceAuthentication first, query if a player Id with the GameCenter Id is online. If it is it sends a message to it to disconnect and then proceeds to authenticate with the GameCenter id on device 2?



No, i tested this with two authentication requests and it only gets triggered after the first authentication.

You could do a device-auth first, but it seems like a more complicated solution if you can just do it when the player auths.

Try out the isOnline check with two GameCenter requests and see if it works as ive only tested with AuthenticationConnectRequest.



I need to re-open this as I still haven't been able to fix this.

I've create a collection where I store the isOnline flag on AuthenticationResponse script.

I started the game on a device and after the first time authenticating it the isOnline flag was set to true. 

If I try to log in with the same user on another device the flag would have already been set to true from the first user anyway so this doesn't seem like a good solution.

I saw a post from Sean on the thread below saying that he had created a workpackage for this. Is it available by any chance?



Login to post a comment