iOS Game Center - what do I do with my leaderboard button if their is no authenticated user?

Hi everyone,

I have a sort of general practice question with game center. Here is the situation:

  1. I have a show leaderboard and a show achievements button on my game main menu.

  2. For google play, you can request a user initiated login. So if the user is not logged in and they hit this button, I simply request a login first and then show it after they login.

  3. For iOS, there is no login request! What exactly should I do if there is no authenticated user and the user hits this button? Is there a way to request the authentication view again? Should I display a popup telling them the feature is only available if they login with game center? What have other developers done here?

Thanks in advance!

Both methods will lead you to a call back that will let you know if the user got signed in.  See: http://docs.coronalabs.com/plugin/gameNetwork-apple/init.html

Rob

Hi rob, I actually have this code you referenced implemented already. What happens is when the app starts the game center authentication view appears. If the user closes it without logging in, then when they hit ny show leaderbiard or achievement button nothing happens. I dont see anything in the log either. Any ideas?

If they didn’t login you will get an event.data that is false (or something like that).  Set a flag that you can then later check to hide the buttons. 

Also, Apple may try to log them in again when you call the .show() or .request().

Rob

Apple unfortunately doesn’t try to log them in again when you make a call to .show() or .request() after the user has declined the first auth screen.

So it sounds like the best practice is to hide the buttons if the user declines auth? I just wish I didn’t have to because I want them to see the features they can get when they do auth with game center.

Hi @spacewolf,

Are you sure that if you :init() Game Center again (following some previous user rejection to log in) that it won’t show the login prompt again? I’d be curious to know exactly what happens in that case.

Brent

Hi Brent,

I did try this and it just says that it has already called init and I can’t call it again. I also tried unloading the gameNetwork module, loading the gameNetwork module again, and then calling init but it still won’t bring up the auth view again.

What if you try to do another type of GC request, like “loadLocalPlayer”? Does that bring up the login again?

Brent

I actually haven’t tried that request yet. I’ll see if it works or not

Both methods will lead you to a call back that will let you know if the user got signed in.  See: http://docs.coronalabs.com/plugin/gameNetwork-apple/init.html

Rob

Hi rob, I actually have this code you referenced implemented already. What happens is when the app starts the game center authentication view appears. If the user closes it without logging in, then when they hit ny show leaderbiard or achievement button nothing happens. I dont see anything in the log either. Any ideas?

If they didn’t login you will get an event.data that is false (or something like that).  Set a flag that you can then later check to hide the buttons. 

Also, Apple may try to log them in again when you call the .show() or .request().

Rob

Apple unfortunately doesn’t try to log them in again when you make a call to .show() or .request() after the user has declined the first auth screen.

So it sounds like the best practice is to hide the buttons if the user declines auth? I just wish I didn’t have to because I want them to see the features they can get when they do auth with game center.

Hi @spacewolf,

Are you sure that if you :init() Game Center again (following some previous user rejection to log in) that it won’t show the login prompt again? I’d be curious to know exactly what happens in that case.

Brent

Hi Brent,

I did try this and it just says that it has already called init and I can’t call it again. I also tried unloading the gameNetwork module, loading the gameNetwork module again, and then calling init but it still won’t bring up the auth view again.

What if you try to do another type of GC request, like “loadLocalPlayer”? Does that bring up the login again?

Brent

I actually haven’t tried that request yet. I’ll see if it works or not