0

My app uses Game Center. I try to log the user when the VC loads. If he was previously logged - great, it logs him in with the notification on top. If he wasnt logged in - great, it shows the Game Center login VC.

However, i want not to 'jump' on the user with the Game Center login VC when he enters the app. I want to have a button that brings up the Game Center login VC, which is easy to do, so only when he clicks the button, the Game Center login VC will come up.

The problem is - i discovered (through trial and error), that if i try to log the user in, and it fails (for example, the user was not logged in to Game Center at all), and if i dont bring the Game Center login VC at that moment - within the first call of the handler - i cant bring it up later on.

I'll explain - I implemented the button i talked about, which brings the GC login VC up. if i dont try to automatically log the user in on load, the button works as expected. But if i do, and it fails (for whatever reason), the button will not bring the VC up no matter what.

observations -

  • this shows that this is indeed Apple policy.
  • trying to bring the GC login VC up after failed handler login doesnt work at all, not related at all to VC appearance.

I found this question here on stackoverflow, but could not find my answer there.

My questions to you are:

  • Is that intended that you can only call the handler once per app run (Even though VC was not shown at first handler call)?
  • Is it possible to do what i asked? if so - how? I would love to able to try to login without showing VC only if i know it will succeed, so i can 'save' the handler call for the button that shows the GC login VC. I know that the information is available in the handler (according to this), im wondering if there is another way.
  • To conclude my questions - Do i have to 'jump' the user with the login VC the moment i try to log him in? (if there is a GC logged in user on the device, a VC is not required)

I hope this was clear, since its a confusing situation. Sorry for the long post! Thanks alot for your time!

1 Answer 1

1

You keep some NSUserDefaults like 'userHasAttemptedToUseGameCenter'. It starts as NO or undefined, which to you means NO. Then when they press the game center button you set to YES and try to do the game center authentication. From then on every time they open the game (or at least every time they go to a game center related screen / feature, then you do game center authentication.

Even when its working fine because you have a game center user it can be a pain because the 'Welcome back' game center banner will pop down and cover the top part of your games UI for the first few moments.

If you just let the game center authentication come up every time but the user doesn't want it, I think after 3 failed attempts to authenticate iOS will NEVER show the authentication again. Your user will then be totally stuck if they change their mind later and want to use a feature that needs game center. You can detect that case only because game center won't authenticate! And all you can do then is tell the user to go to the Game Center app and log in there. Its hell to test. If one of your test devices gets into this locked out state you have to do a 'Reset all content and settings'.

Please someone chime in if this has gotten any better in iOS8.

5
  • nsuserdefaults settings ends life after app deletion - not sure that this is good practice for games. Mar 4, 2015 at 7:46
  • I thought about saving such a variable - however if the user logs out of game center outside, lets say from the main device 'settings' - the game would not be aware of this and could cause problems.
    – Zephyer
    Mar 4, 2015 at 9:04
  • I thought about saving such a variable - however if the user logs out of game center outside, lets say from the main device 'settings' - the game would not be aware of this and could cause problems. I know that in reality no one really logs out of game center (i think?), but i dont want to take the risk and block users out.
    – Zephyer
    Mar 4, 2015 at 9:04
  • 1
    All that happens in this case is the game will pop up the Game Center login screen again. There's only so much apple will let you do because these APIs are... odd. The approach in my answer is to distinguish between a game center user and a non user. The edge case of someone who was a game center user but now never wants to be logged into that - its a tiny edge case. Design for the majority of cases, and don't fail disastrously for edge cases. Thats the best you can hope for. Mar 4, 2015 at 17:43
  • Thanks Mark. Nice point of view, will consider going that way
    – Zephyer
    Mar 4, 2015 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.