GameCenter - check previous login before calling handler? - ios

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!

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.

Related

Apple Game Center Dialog Stops Responding To Events

I'm starting to integrate Apple's Game Center into an app I'm developing using the Cocos2d-x framework. I've written a very simple wrapper to connect the mostly C++ codebase to the Objective C calls required to interface with Game Center. I display the initial Game Center dialog with the following code:
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:viewController animated:YES completion:nil];
The dialog displays and I'm asked to choose a username. If I pick a username that's already taken, I get the following screenshot:
That's all well and good, but I've found that once I dismiss this popup, I can no longer do anything on this dialog page. I'm able to edit the text in the nickname box, but the Cancel and Next buttons no longer do anything, and I don't receive further notifications about whether or not my username is valid.
I feel it's likely due to some kind of view controller issue where messages are being sent to the wrong place after the popup appears, but since I'm a complete beginner at Objective C programming I have no idea what could be the cause.
So the answer seems to be to somehow trigger Game Center to forget my login information. I also turned on Logging under Settings/Game Center.
I had changed my Apple Login password on the same day this issue started happening, so I think it might be related to the particular device I was using not having synced information for my device sign in and the Game Center information.
One interesting change is that now when I insert an unavailable nickname, I get a list of suggestions that didn't appear before. All buttons now appear to be functional, so I'm in business!

Should touchID be displayed if app minimized

Im implementing touch ID to "unlock" my app, and im not sure if ive run into an apple bug or something i need to handle myself. If i tap the Home button and minimize my app before evaluatePolicy can load the Touch ID prompt, it appears over the home screen.
![not enough reputation to display screenshot, so heres a link]https://www.dropbox.com/s/zrhc60lx87ze7mt/IMG_0016.PNG
Successful/failure/cancel evaluation of this policy does nothing, but when i re-enter the app and cancel it again, touchID seems to be disabled forever until i restart the phone.
Anyone else running into this issue or have an ideas?
P.S. Theres an open radar where errSecUserCanceled is never returned from a cancel button tap, so right now i fall into my errSecAuthFailed case, which could also be the cause.
Answer is no. It should not be be displayed, when minimized.
The problem is IMHO that the code segment is being called again from your app when it goes to the background. For example loadView , didLoad and so on.
Try moving the code, that calls the authentication somewhere else in the program (different method).
For example, if your code uses a textView to enter password, you can implement the authentication within keyboardWillShow or similar.
Hope it helps.

Any way to re-show Game Center login view? (Xcode)

My app attempts to log the player in when it finishes loading, like good little apps should (so says Apple). But if the player chooses to cancel the initial log-in, I wanted the app to re-attempt to authenticate the player if the player taps the leaderboard button in the game. (otherwise, of course, the button couldn't do anything if the player is not authenticated)
Unfortunately, after some research I discovered that Apple does not seem to allow an app try again to re-authenticate the player after the player cancels the first time, until the player exits and re-enters the game. (If the player cancels three or so times, Apple goes aggro and disables Game Center from the app on that device entirely. Even logging into Game Center from the stand alone app won't help after that point.)
Is there any way around this so that my app can attempt the authentication both when the app loads, and any time the player taps leaderboard button while not logged in? Or do I just have to have my leaderboard button display a message when not authenticated saying that Apple's being dumb and overprotective and not letting my app respond the way it should? (Perhaps not quite in those words...)
I've used an alternative approach that might solve your requirement. When they tap on the leaderboard, check the Game Center connection state.
If it is not GCPConnectionStateEnabledFully then throw up an alert like this "Error connecting to Game Center. Please make sure you are signed into Game Center and check your internet connection". Then inevitably they will leave your app to check and when they return the Login prompt will appear a few seconds after they return to the app.
Testing note: When you are testing these scenarios you might cancel the login prompt 3 times. If you do that it will stop prompting you altogether and you need to reset all settings in the Settings app. I remember this being really frustrating.

UIAlertView is not shown when returning from sleep mode in iOS app

My app must sometimes show an UIAlertView when the Home button or the locking button is pushed or when the notification center is shown.
I show the Alert from the applicationWillResignActive delegate's method and everything is ok when home button is pushed or when notificacion center is shown. But there is a problem if the button which is pushed is the locking button (on/off button).
In that case, the Alert is not shown when I return to the app (if I used the Home button it is there). I don't do anything else in other AppDelegate methods which are executed. Also, then, when I show a new Alert (any Alert in the app) the Alert which hasn't been shown when I returned is shown after I dismiss the new one.
Please, could anybody help me?
Thanks in advance.
THE EASY, GIVE ME REP ANSWER:
When the app is put into the background, the app is suspended. Part of this process is closing open alert views.
THE I ACTUALLY KNOW WHAT I'M TALKING ABOUT ANSWER:
The logic behind this is that when the user hits the home button when an alert is displayed, they might be going to look for information on how to answer the alert. However, when the sleep button is pressed, the user has stopped using the device altogether. Apple knows that if they unlock thier device again 3 hours later and see something like Confirm Deletion, they will have absolutely no idea what they were just doing and what to do now.
This is known to cause a serious condition known as what-in-the-world-am-I-supposed-to-do-now-itis. Symptoms of this condition include hitting the round button at the bottom of the screen and subsequently holding on your app icon until it jiggles. They then hit the little 'x' button. This is not good for developer's pockets.

How to show game center authenticate login alert multi times?

I'm building a game and I want to make game center something like the app High Moon. Which is when authenticating, when Apple's game center login alert shows, if the user tap cancel, I will show an alert, when my alert dismisses, I want to show Apple's game center login again. This means if the user doesn't login to game center, he can't play the game.
The problem is that,when I call authenticate method to show the login alert again, Apple's game center login alert doesn't show. Someone know how to show it again? Thanks.
Actually you can't.
And the interesting part in this, if the user presses cancel three times in a row, the dialog won't appear again. Ever. Even if you have the authentication code called, the user has to go to the game center app, login, then come back.
Source: GameKit Docs.

Resources